I write windows batch file for copying war file. Then I remove the directory that contain war file but the directory does not disappear. See my command
copy D:\target\*.war D:\new_target
IF exist D:\target (
rmdir D:\target /s /q
)
But my folder "target" can't delete.Is there any comments for delete folder batch command.
I use rd
instead of rmdir
but the same result.I use Windows 7, 64bit.
MC ND explained most likely the reason for denied deletion. Another one would be no permission to delete the folder with the used user account according to NTFS permissions.
@echo off
if exist "D:\target\*.war" (
cd /D D:\
copy "D:\target\*.war" "D:\new_target"
rd "D:\target" /s /q
)
Double quotes are used around all folder/file specifications in case of your real folders contain 1 or more spaces.
The batch file sets the current working directory to root of drive D: to avoid that directory D:\target
is the current working directory of command line interpreter running this batch file.
But the executed batch file should nevertheless not be stored in D:\target
.