Delete filename characters in DOS

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

JTagle

Thread Starter
Joined
Jul 8, 2005
Messages
5
I have a list of 65 files that have a file name similar to this: D050708.P00535.C00 and I need to delete D050708. AND .C00 leaving only P00535. The P00535 changes for all the 65 files, that is what makes them unique. Is there a DOS command that I can use to do this for all the files so that I don't have to it one-by-one?
 
Joined
May 21, 2005
Messages
579
Caveat: I don't know what version of DOS you're using. And I assume you know what you're doing and that removing the first and last parts of the names won't make the files unusable.

That said, the 'rename' command could be a solution - it can be used with a wildcard character for the new file name. Both the old filename and the new filename must be on the same drive.

CAUTION - I'd copy at least some of those files to a floppy first and then test the command on the files on the floppy before running it on the hard drive.

So after copying some files to the floppy, go into dos and navigate to the floppy drive.

A:\>ren D050708.*.C00 *

Then check the contents of the floppy with the dir command. If all looks OK, repeat on the hard drive.
 

JTagle

Thread Starter
Joined
Jul 8, 2005
Messages
5
Surreal2, thanks for the info, I tried it and it didn't work. After looking at it, I realized that it is missing the new file name.

ren D050708.*.C00 *

looks for the file to rename, what I need is the new filename, which I need it to be P00535.
 

Squashman

Retired Trusted Advisor
Joined
Apr 4, 2003
Messages
19,786
Another thing I could so easily in a Linux Bash Script. I always have a hard time writing Batch Files. There are alot of Batch File Rename programs available for download. See if any of those might work.
 
Joined
May 21, 2005
Messages
579
JTagle said:
Surreal2, thanks for the info, I tried it and it didn't work. After looking at it, I realized that it is missing the new file name.

ren D050708.*.C00 *

looks for the file to rename, what I need is the new filename, which I need it to be P00535.
The new filename is the * that follows the space after the old filename. It takes info from the * in the old filename, which represents the changing numbers, and uses it for the new filename.

For example:

ren *.doc *.txt

will change all extensions from .doc files to .txt, but leaves the first part of the filename unchanged.

Did you type a space between the last 0 of the old filename and the second * ?

Syntax: ren [oldfilename] [newfilename]
Equates to: ren [D050708.*.C00] [*]

Note the spaces between each item. You don't type in the square brackets, of course.

Maybe try changing/removing one item at a time:

ren D050708.*.C00 D050708.*

then

ren D050708.* *
 

JTagle

Thread Starter
Joined
Jul 8, 2005
Messages
5
sekirt,

AF5 solved the problem! That is an awesome little app.

Thank you.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top