dr.zick Posted February 11, 2009 Share Posted February 11, 2009 Sorry, if this is off-topic but I tried googling it and couldn't find an answer. Is there a way to use the windows command prompt to mass rename a bunch of files, mainly photos from a vacation, but I have other things that I would like to do. My camera names the files DSC-xxxx.jpg ... Can I remove the DSC-x and keep the last 3 digits and the .jpg at all. I don't want to have to manually rename every file if I don't have to. Thanks for the help. Link to comment Share on other sites More sharing options...
rv31 Posted February 11, 2009 Share Posted February 11, 2009 Try this vb script, copy all this code into notepad and save as renamer.vbs or whatever (have "all files" selected in the save dialogue).Run the script and choose the folder where your pictures are, if they are on the desktop you will need to navigate in the folder dialogue to the full path i.eC:\Documents and Settings\Owner\Desktop\New Folder etc... or whateverSo this script only works on jpg files or ".jpg" to be precise..... And will only remove the first 5 characters in the filename i.e DSC-x and leave the rest..dim fsodim folderdim filedim fnamedim ObjFSOdim folderpathset fso = createobject("Scripting.FilesystemObject")set objShell = CreateObject("Shell.Application") set objFolder = objShell.BrowseForFolder(0, "Example", 0, ssfAll) if objFolder is nothing then Wscript.Echo "Script Error: Please select a folder!" Wscript.Quit end if folderpath = objFolder.ParentFolder.ParseName(objFolder.Title).Path & "\"set folder = fso.GetFolder(folderpath)for each file in folder.files if right(file.name,3) = "jpg" then fname = mid(file.name,6,(len(file.name)-5)) fso.movefile folderpath & file.name,folderpath & fname end ifnext Link to comment Share on other sites More sharing options...
billtodd Posted February 11, 2009 Share Posted February 11, 2009 My impression is that Microsoft's command language doesn't offer the level of wild-carding rename facilities that would be required. See http://rename.lupasfreeware.org/lupasrename.php for some freeware that should do the job easily.- bill Link to comment Share on other sites More sharing options...
Redhatcc Posted February 15, 2009 Share Posted February 15, 2009 http://www.mediachance.com/free/renamer.htm Link to comment Share on other sites More sharing options...
gunsmokingman Posted February 16, 2009 Share Posted February 16, 2009 Here is my script, you have to Drag and drop the folder with the files you want to rename.This replace the first 5 characters, dsc-x, then copies the file with the new name then deletesthe old file. I also included a text report of what files where changed.Save As ReName.vbsOption Explicit Dim Act :Set Act = CreateObject("Wscript.Shell")Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")Dim Dsk :Dsk = Act.SpecialFolders("DeskTop") & "\" Dim A1, C1, F1, F2, F3, F4, PF, Ts'-> Make Sure We Drag And Drop Some Thing If Wscript.Arguments.Count = 0 Then MsgBox "This Needs A Folder To Be Drop" & vbCrLf & _ "And Drop On To This Script.",4128, "Error 1" WScript.Quit(0) Else For Each F1 In WScript.Arguments'-> Make Sure It A Folder We Are Using If Right(InStr(F1,"."),5) Then MsgBox "Error This Is A Single File, Please" & vbCrLf & _ "Drag A Folder On To This Script",4128, "Error 2" WScript.Quit(1) Else'-> Get The Folder Path Set PF = Fso.GetFolder(F1)'-> Collect The Files In The Folder For Each F2 In PF.Files A1 = 0'-> Filter Out The Files To Be Renamed If InStr(LCase(F2.Name),LCase("dsc")) Then A1 = 1 C1 = Left(F2.Name,5) C1 = Replace(F2.Name,C1,"") F4 = F4 & _ " Old File Name " & F2.Path & vbCrLf & _ " New File Name " & Replace(F2.Path,F2.Name,C1) & vbCrLf & _ " Copy Time " & Time & vbCrLf Fso.CopyFile F2.Path, Replace(F2.Path,F2.Name,C1), True Fso.DeleteFile(F2.Path),true End If Next End If Next'-> Build The Text Report If A1 = 1 Then Set Ts = Fso.CreateTextFile(Dsk & PF.Name & "_Rename.txt") Ts.WriteLine " Folder Path " & PF.Path & vbCrLf Ts.WriteLine F4 Ts.Close Act.Run(Chr(34) & Dsk & PF.Name & "_Rename.txt" & Chr(34)),1,True End If'-> No Files Where Renamed If A1 = 0 Then MsgBox "No Files Where Renamed", 4128, "No Files Renamed" End If Link to comment Share on other sites More sharing options...
perpetuations Posted February 16, 2009 Share Posted February 16, 2009 http://www.zipghost.com/maybe this software can solve your problem.I learnt of that ACDsee can mass rename a buntch of files. Link to comment Share on other sites More sharing options...
perpetuations Posted February 16, 2009 Share Posted February 16, 2009 You can also use the command like:rename DSC-???? or rename DSC-* Link to comment Share on other sites More sharing options...
Yzöwl Posted February 16, 2009 Share Posted February 16, 2009 Whilst this is a relatively easy task to perform in [batch file | command line] I think you should change tack with your task. Once you change the auto-naming sequence and in time remove files etc. even the numbering serves little purpose.I'd suggest thinking about, simply taking every .jpg in foldername and renaming them all sequentially, (say 001.jpg - 999.jpg). This would also rule out any possibility of overwriting files ending with the same three digits too. Link to comment Share on other sites More sharing options...
spacesurfer Posted February 16, 2009 Share Posted February 16, 2009 I rename my pics as YYYY.MM.DD_##.jpg, where ## is the counter, so that I know exactly when that pic was taken. I also group them by month. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now