xunil76 Posted July 23, 2005 Posted July 23, 2005 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.jpgand i want to rename them to: 164_00.jpg thru 164_50.jpgso 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.jpgand i want to rename them to: 181_00.jpg thru 181_50.jpgso 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.jpganyone 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.
SnakeOiler Posted July 23, 2005 Posted July 23, 2005 I would say it has to do with the wildcard matching. Try using a variable for your number value of the file name and create a loop for the renaming.
xunil76 Posted July 23, 2005 Author Posted July 23, 2005 I would say it has to do with the wildcard matching. Try using a variable for your number value of the file name and create a loop for the renaming.<{POST_SNAPBACK}>i don't quite follow you.......example?
jcarle Posted July 23, 2005 Posted July 23, 2005 (edited) 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.jpgNot the most efficient method, but this will work. Edited July 23, 2005 by jcarle
gunsmokingman Posted July 23, 2005 Posted July 23, 2005 (edited) 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 locationF:\Documents and Settings\Gunsmokingman\DesktopLooking For This LocationC:\Temp1Red 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 QuitGreen Is The New Name Change to Suit Your needsEG (FPath & "\EG 181_50.jpg")Orange The Number Of Files If You Have 50 filesthen set the Number to 50 Change this Fso.CopyFile to Fso.MoveFile if you only want one fileleft if it left as copy it will leave the original plus new name in the folder.Re Edit CodeDim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")Dim INTA : INTA = 1-1strComputer = "." 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 IfNext Edited July 24, 2005 by gunsmokingman
SnakeOiler Posted July 24, 2005 Posted July 24, 2005 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.jpgNot the most efficient method, but this will work.<{POST_SNAPBACK}>Yes, this could be refined to:for /L %i in (1,1,50) do ren 164__%i.jpg 164_%i.jpg
xunil76 Posted July 24, 2005 Author Posted July 24, 2005 thanks for the responses guys......i did a little searching, and came up with an awesome, user-friendly solution. it's called Better File Rename. it's an explorer extension that has TONS of features, and is really easy to use.if anyone is interested, check it out at: Better File Rename for Windows
Martin Zugec Posted July 24, 2005 Posted July 24, 2005 a.)for /f "usebackq delims=_. tokens=1-3" %%i IN (`dir /b 164*.jpg`) DO ren %%i__%%j.%%k %%i_%%j.%%kb.)for /f "usebackq delims=_. tokens=1-3" %%i IN (`dir /b __hr*.jpg`) DO ren __hr_page_%%k.jpg 180_%%k.jpg
jcarle Posted July 24, 2005 Posted July 24, 2005 Now all the leet DOS coders are coming out of the woodwork... awww... I miss the days of DOS!
xxg00chxx Posted July 25, 2005 Posted July 25, 2005 Try using the "?" wildcard instead... If I remember correctly, "?" denotes just "1" character, rather than "1 or more" as the "*" wildcard implies.
Martin Zugec Posted July 25, 2005 Posted July 25, 2005 2jcarle: You must look forward to Monad and try to learn .NET and C as fast as possible
totoymola Posted July 26, 2005 Posted July 26, 2005 Try using the "?" wildcard instead... If I remember correctly, "?" denotes just "1" character, rather than "1 or more" as the "*" wildcard implies.<{POST_SNAPBACK}>true
jaclaz Posted July 26, 2005 Posted July 26, 2005 Out of topic, but not much, here is a GREAT file renaming utility (FREEWARE):http://www.1-4a.com/rename/and it also features Star Trek dates:http://www.1-4a.com/rename/stardate.htm(not actually useful,though) jaclaz
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now