Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows batch file 'del' not working

I am trying to do the following in a batch file on Windows 7:

del "./cfg/config.cfg"
del "./cfg/server_blacklist.txt"

I tried these variations too:

del ./cfg/config.cfg
del ./cfg/server_blacklist.txt

del "cfg/config.cfg"
del "cfg/server_blacklist.txt"

del cfg/config.cfg
del cfg/server_blacklist.txt

Without using the "-characters the command prompt tells me the given parameter is not correct.

With using the "-characters, it's telling me that it can't find the path, even though it's there, including the files in it.

How can I fix this?

like image 874
Codecat Avatar asked Feb 26 '23 18:02

Codecat


1 Answers

Use backslashes:

del ".\cfg\config.cfg"
...

del is a shell built-in command and those traditionally behave a little weird compared with the rest of the system. While the Windows API usually doesn't care what kind of slashes you use, cmd's built-in commands do care.

like image 57
Joey Avatar answered Mar 05 '23 04:03

Joey