Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch script to delete files

Tags:

batch-file

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%?

like image 462
Satheesh Avatar asked Dec 07 '12 13:12

Satheesh


People also ask

Can you delete files using cmd?

To delete a file, use the following command: del "<filename>" . For example, to delete Test file. txt , just run del "Test File. txt" .

How do I force delete a batch file?

Force delete using WindowsWith the command prompt open, enter del /f filename , where filename is the name of the file or files (you can specify multiple files using commas) you want to delete.


1 Answers

You need to escape the % with another...

del "D:\TEST\TEST 100%%\Archive*.TXT" 
like image 183
Russ Freeman Avatar answered Sep 20 '22 20:09

Russ Freeman