Computer question

ricmac25

Token Cuban Guy
Joined
May 22, 2003
Messages
1,769
Location
Hialeah, FL (near miami)
Alright, here's the dilemma:

I have 1400 files with names such as:

P09001
P10002
P11101

I need to remove the P from all of these file names.

I've tried renaming them in dos, but it only let's me change the first letter not remove it. I tried using a space but it just puts a space in front and it still doesn't do what I need. If there is a way to remove the letter I do not know it.


Any ideas on how to do this?
 
I tested this before I posted. It works for me. Make sure you are in the directory that has the files you want to rename and try a cut & paste of what I typed. I rechecked it on the command box in XP and Win 2K and it works in both.
 
OK, I'm wrong. I mis-read that you only want the number and not a replacement of the "p". My bad. :(
 
That did it! Thanks AVB. It's funny I had found that on google but in my mind when I read it I thought it said free trial.



That saved me from a very tedious situation.

Thanks! :thumbs:
 
So what were all these files for anyway?

1400 of 'em?

Dave
 
wow I had a similar problem before.

I need to get that utility!


why wouldn't ren P*.* *.* work?

JC
 
Lumberg, it won't work because you aren't renaming anything with that. P*.* says take everything that begings with "P". the *.* says take everything including "P" so there is no rename.
 
I tried the ? thing, didn't work either.


So what were all these files for anyway?

1400 of 'em?

Student ID pictures. I needed to get them from one program to another. But when I exported it from the first program it put a P infront of their ID number.
 
Where was I in your time of need? ???
The DOS batch for command is really powerful.

for %d in (p*) do echo %d >> listing
for /F "delims=p " %f in (listing) do ren p%f %f

If you want to put it in a .bat file, trade all % for %%
 
MonkeyK said:
Where was I in your time of need? ???
The DOS batch for command is really powerful.

for %d in (p*) do echo %d >> listing
for /F "delims=p " %f in (listing) do ren p%f %f

If you want to put it in a .bat file, trade all % for %%
Damn

I used to call myself a batch file guru and even I dont understand that completely!
 
little tutorial for a nearly dead scripting language:

For acts on everything in the list in parenthesis, by default this is a directory listing, but it could be some DOS command.
The %d is a variable to hold the current thing that for is acting on.
so

for %d in (p*) do echo %d >> listing

says for each file that starts with a "p", output its name to a file called listing. ">>" means to append output. The first line creates a list of all files that you want to act on.

The /F option for the for command says to act on the file contents

for /F "delims=p " %f in (listing) do ren p%f %f

says to process all files in the file listing. "delims=p " says to break each line up, using the letter p as a delimiter. This result in the variable %f being the name of each file after the "p". The second line takes the "p" off of each file name, sets that to a variable and then renames the the file.
 
Top