# Delete filename characters in DOS



## JTagle (Jul 8, 2005)

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?


----------



## Surreal2 (May 21, 2005)

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 (Jul 8, 2005)

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 (Apr 4, 2003)

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.


----------



## Surreal2 (May 21, 2005)

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.* *


----------



## sekirt (Mar 28, 2003)

You can play with DOS but for doing it through Windows, a renaming program works real well. AF5 is freeware. There are others.

http://www.fauland.com/

sekirt


----------



## JTagle (Jul 8, 2005)

sekirt,

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

Thank you.


----------



## sekirt (Mar 28, 2003)

I like it.
:up: 

sekirt


----------

