Batch script to delete files

Satheesh picture Satheesh · Dec 7, 2012 · Viewed 572.1k times · Source

I have a batch script as follows.

D:
del "D:\TEST\TEST1\Archive\*.TSV" 
del "D:\TEST\TEST1\Archive\*.TXT"
del "D:\TEST\TEST2\Archive\*.TSV" 
del "D:\TEST\TEST2\Archive\*.TXT"
del "D:\TEST\TEST 100%\Archive\*.TSV" 
del "D:\TEST\TEST 100%\Archive\*.TXT"

The above code deletes all the ".txt" and ".tsv" files from all the folders except from the folder TEST 100%. For deleting the files from TEST 100% i am getting the error as The Path could not be found. I guess the % symbol in the folder name creates the issue. Can anyone guide me to resolve the issue and to delete the files from the folder TEST 100%?

Answer

Russ Freeman picture Russ Freeman · Dec 7, 2012

You need to escape the % with another...

del "D:\TEST\TEST 100%%\Archive*.TXT"