Del command in command prompt

16.5k views Asked by At

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?

3

There are 3 answers

8
Greg Hewgill On BEST ANSWER

Use \ instead of / as the path separator:

del %userprofile%\AppData\Roaming\MyFolder\myfile.txt
3
Lizzy On

Try replacing %userprofile% in the command:

%userprofile%/AppData/Roaming/MyFolder/myfile.txt

with your user account name. If it still does not work, try addressing the full path of the file you want to delete.

0
SlySlacker On

Use this:

del /f /q “file_path” 

Also, use backslashes in your file path.