Computing.Net > Forums > Disk Operating System > delete files with ' - ' in filename

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

delete files with ' - ' in filename

Reply to Message Icon

Name: jake1025
Date: September 19, 2004 at 20:58:04 Pacific
OS: xphome
CPU/Ram: 800/128
Comment:

when i try to delete a file in dos with a whitespace, a dash, and another whitespace together in a filename (ex: "str1 - str2.txt"), the file wont delete. How do I get around this without renaming the file?

Command i'm using:
del /f/q "D:\www\trash\whatever - something.txt"

if i try to copy the same file, it copies successfully; so it's a probably a problem with delete.

any suggestions on how i could delete this file? (without renaming, or using explorer)

thanks,
jake



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: September 19, 2004 at 23:56:43 Pacific
Reply:

Hi Jake,

What OS are you using?

Seems like xphome, since you mention explorer.

If so, which command prompt are you using, cmd.exe or command.com?

And when you do this:

del /f/q "D:\www\trash\whatever - something.txt"

do you get a message or do you simply get the prompt back and the file stays stuck.

If you get a message, it would help to post it.



0

Response Number 2
Name: jake1025
Date: September 20, 2004 at 16:30:33 Pacific
Reply:

Mechanix,

Yes, I'm using XP Home (it says so at the top of my post).
I'm using cmd.exe in the system32 folder.
And when I try to delete, a message is returned that says the file could not be found. But the file is there, i've dir/p'd the directory, checked my syntax, and the file exists.

Thanks for the response,
Jake


0

Response Number 3
Name: IVO
Date: September 21, 2004 at 01:59:18 Pacific
Reply:

A way to work around is to use the short format (8.3) name in delete. To get the short name type the Dir /X command, i.e.

Dir /X "D:\www\trash\whatever - something.txt"

then use the returned string in the old 8.3 format as operand of the Del command.


0

Response Number 4
Name: Mechanix2Go
Date: September 21, 2004 at 02:07:34 Pacific
Reply:

Hi Jake,

This works:

type nul > "s:\www\whatever - something.txt"

del /f/q "s:\www\whatever - something.txt"

but this does not:

type nul > "s:\www\whatever - something.txt"

attrib +h "s:\www\whatever - something.txt"

del /f/q "s:\www\whatever - something.txt"

because the file is hidden.

Your command line does not use the
dir /ah

so I guess it's not hidden, UNLESS you have the environment varible 'dircmd' set to /ah

You could probably have just deleted it in Explorer, but since we're in this deep, let's keep going and solve the prob.



0

Response Number 5
Name: jake1025
Date: September 21, 2004 at 18:47:16 Pacific
Reply:

Hey thanks guys, I got it to work.

The reason I'm not using explorer is because i'm making a file manager in php for people who pay me to host their websites. PHP has really crappy built-in file functions that are limited in functionality, so I decided to use it's shell command to do stuff like delete, copy, etc. I wish it was as easy as using explorer.

Thanks,
Jake


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: delete files with ' - ' in filename

Deleting folder with spaces... www.computing.net/answers/dos/deleting-folder-with-spaces/11883.html

Deleting Files by Date?? www.computing.net/answers/dos/deleting-files-by-date/10700.html

Restoring Deleted Files with DOS www.computing.net/answers/dos/restoring-deleted-files-with-dos/13956.html