Cannot Delete File with Spaces


Windows cannot delete some files with spaces, especially if the space is at the end of the file name. The delete command trims the spaces from the name and then simply cannot find such file. Old fashion DEL command like this

DEL /F “F:\Folder1\Folder2\File Name “

still may not work.

In order to resolve the issue, first identify old-fashioned 8.3 file name

DIR /A /X “F:\Folder1\Folder2”

Now, when you see the file name, simply use it in the following command

DEL /F “\\?\F:\Folder1\Folder2\File Name *”

Another way to do it is to use file sharing. Some files can be deleted from remote computer, if the file is located within the shared folder.

Third way can be to use the remote system that understands non-Windows special characters, for example LINUX or MAC computer. Share the Folder2 folder as SharedFolder with Everyone FullControl

On the remote LINUX machine mount this folder

apt-get install cifs-utils
mount -t cifs //ServerName/SharedFolder /mnt/SharedFolder

Delete the file

rm -f –no-preserver-root /mnt/SharedFolder/File Name

Unmount the shared file system

unmount /mnt/SharedFolder

 

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: