batch script to delete a file after the above process completed

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
kchan
Posts: 1
Joined: 01 Feb 2017 20:26

batch script to delete a file after the above process completed

#1 Post by kchan » 01 Feb 2017 20:44

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.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

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

#2 Post by aGerman » 02 Feb 2017 02:42

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

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

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

#3 Post by Squashman » 02 Feb 2017 07:26

Some programs do not respect the wait option. Remove the start command and just run the executable directly. Then delete any files after that.

Post Reply