Page 1 of 1

batch script to delete a file after the above process completed

Posted: 01 Feb 2017 20:44
by kchan
Hi

I have a batch script run.bat running with the following command

start /wait c:\*\*\*\doscan.exe c:\scanfolder

how do i delete the item in scanfolder after this command end?

delete c:\scanfolder doesn't seems to work and i want to ensure the process completed then run the delete.

Please advise.

Re: batch script to delete a file after the above process completed

Posted: 02 Feb 2017 02:42
by aGerman
Do you want to delete C:\scanfolder or rather its contents?

This would remove the whole folder:

Code: Select all

rd /s /q "C:\scanfolder"


This would remove the contents:

Code: Select all

for /d %%i in ("C:\scanfolder\*") do rd /s /q "%%~i"
del /f /q "C:\scanfolder\*.*"


Steffen

Re: batch script to delete a file after the above process completed

Posted: 02 Feb 2017 07:26
by Squashman
Some programs do not respect the wait option. Remove the start command and just run the executable directly. Then delete any files after that.