Del command in command prompt

newbieguy picture newbieguy · Jun 11, 2015 · Viewed 9.3k times · Source

I want to, for example, delete a file in AppData/Roaming/MyFolder/myfile.txt.

I use command prompt and typed this: del %userprofile%/AppData/Roaming/MyFolder/myfile.txt

But then the command prompt said: Parameter format not correct - "ppData"

Then I think again and used %appdata% and typed:del %appdata%/MyFolder/myfile.txt

But the command prompt said: Invalid switch - "MyFolder"

How to delete myfile.txt using %userprofile% or %appdata%? Is my syntax wrong?

Answer

Greg Hewgill picture Greg Hewgill · Jun 11, 2015

Use \ instead of / as the path separator:

del %userprofile%\AppData\Roaming\MyFolder\myfile.txt