Home » Questions » Computers [ Ask a new question ]

How can I create a script to delete a file?

How can I create a script to delete a file?

I have a file in a given folder that I want to delete by either running a script or clicking on some shortcut, but I have no idea how to do so.

Asked by: Guest | Views: 73
Total answers/comments: 1
Guest [Entry]

"Open up notepad and copy the following in to it:

Del C:\""Program Files""\""Our crappy software""\""file to be deleted.txt""

Save this as either a .cmd or .bat file.

Run it!

You can either double click or place a shortcut.

This will allow you to delete from anywhere, alternatively you can use:

Del ""file to be deleted.txt""

as long as the working directory is correct, but it is best to use actual paths.

FYI - you do not need quotes for one word names, you just use them where there is a space, alternatively, you can use the old 8.3 file format (for example, go to command prompt and a directory with long files and type dir /x then you can use file~1 instead of ""file to be deleted.txt"""