Jump to content

Need help with weird command prompt problem


xunil76

Recommended Posts

ok, so i've got a bunch of sequential files in a directory that i'm trying to rename all at once thru the commant prompt, but i'm having a problem (and yes, i made sure i'm in the correct directory first....)

the file names are: 164__00.jpg thru 164__50.jpg

and i want to rename them to: 164_00.jpg thru 164_50.jpg

so in the command prompt i type:

ren 164__**.* 164_**.*

but it does absolutely nothing?!

also, i have some files named: __hr_Page_00.jpg thru __hr_Page_50.jpg

and i want to rename them to: 181_00.jpg thru 181_50.jpg

so in the command prompt i type:

ren __hr_Page_**.* 181_**.*

but i end up with files named: 181__Page_00.jpg thru 181__Page_50.jpg

anyone have a clue why this isn't working? i'm on WinXP Pro SP2, if it makes a difference....and using cmd.exe, not command.com, as it's much easier to work with long filename support.

Link to comment
Share on other sites


for %i in (00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50) do ren 164__%i.jpg 164_%i.jpg

Not the most efficient method, but this will work.

Edited by jcarle
Link to comment
Share on other sites

I am not a script writer, but I came up with this script, It only limitation so far is the amount loops I have it set at = 5.

It is set for text files in this script, but change the extention name to suit your needs

Test this from this location

F:\Documents and Settings\Gunsmokingman\Desktop

Looking For This Location

C:\Temp1

Red Is The File It Looking For With Wild Card

Blue Are Some Varibles For Location File Name

Purple Is A Counter That I Added To Count The loops And Quit

Green Is The New Name Change to Suit Your needs

EG (FPath & "\EG 181_50.jpg")

Orange The Number Of Files If You Have 50 files

then set the Number to 50

Change this Fso.CopyFile to Fso.MoveFile if you only want one file

left if it left as copy it will leave the original plus new name in the folder.

Re Edit Code

Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")

Dim INTA : INTA = 1-1

strComputer = "."

  Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

  Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile Where FileName Like '164%'")

For Each objFiles in colFiles

INTA = INTA+ 1

FPath = UCase(objFiles.Drive & objFiles.Path)

  CreateObject("Wscript.Shell").popup ObjFiles.Name,3,Date(), 0 + 32

  Fso.CopyFile(ObjFiles.Name),(FPath & "\Test" & INTA & ".Txt" )

  If INTA = 5 Then

  Set objWMIService = Nothing

  Set colFiles = Nothing

  Exit For

  End If

Next

Edited by gunsmokingman
Link to comment
Share on other sites

for %i in (00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50) do ren 164__%i.jpg 164_%i.jpg

Not the most efficient method, but this will work.

Yes, this could be refined to:

for /L %i in (1,1,50) do ren 164__%i.jpg 164_%i.jpg

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...