How to delete a file that has a trailing space or special character

I came across this article recently when i needed to delete a file that had a trailing space in its name… In case you are not aware it is normally not possible to delete files with spaces in the name because windows by default strip any trailing spaces from the command you are running… so if you need to delete that pesky file that you just cant delete you can use the the “del” command so long as you use the “\?” escape character at the start of the file name:

example

You want to delete “C:tempfilename “ (note the space at the end.) then the command will be (including the “”):

del “\?c:tempfilename “

More info at You cannot delete a file or a folder on an NTFS file system volume

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: