• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Make Shortcut that Deletes the File?

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

MachineTheory

Registered
Joined
Jun 22, 2013
Location
New York
I would like to make a shortcut which deletes the file it targets.
What command line parameters do I use? Proper syntax needed. Windows 7.

I frequently have to clear the cache of a particular program by deleting a file. I would like to streamline this process by creating a shortcut which deletes it.
Would the target field read something like this?:
"E:\Program Directory\Cache File.txt" -delete

Thank you.
 
I think what you actually want is to create a batch file. Do a google search for "write a batch file to delete a file".... several tutorials come up.
 
I think what you actually want is to create a batch file. Do a google search for "write a batch file to delete a file".... several tutorials come up.

+1.


Just create a new text file with the following line:
Code:
del "E:\Program Directory\Cache File.txt"
and save it as whatever.bat.

Double click it and it will delete whatever file you have pointed it to. Make sure that you have the 'hide extensions of known file types' turned off otherwise Windows will save the file as 'whatever.bat.txt' and it won't work.
 
Awesome. That works; thank you very much.
I still feel a bit wary letting the system automatically delete something; but now I have the choice.

Hmm. There is one problem. When the test file is deleted, it is not sent to the Recycle Bin. It is apparently deleted outright. Can I set it to send the file to the recycle bin, just in case I need to un-delete it?
Thanks.
 
I don't believe it's possible with batch, you'll have to use powershell instead. It's a little more involved, but still fairly simple. When I'm not posting from my phone I'll post an example. I'm sure you could Google some code snippets as well.
 
Back