phillyman2004 Posted March 11, 2006 Posted March 11, 2006 Just got a new scanner........and of course its got crappy software ........i need a small batchfile that just does the following ==================Asks Which Prefix would you like to use?(user enters book)Which Page does This collection start at?(User picks 2)File then proceeds to rename each file in that directory following the directions from the userbook 002book 004book 006..book 116====================I am having this problem because my scanner only scans 1 side at a time .....and wont skip every other number......So i am hoping that one of you batch file guru's can write me a small little file that i can run on the first batch of scans for odd numbered scans ......then on the second batch for the even scans .....then i can put them together in a folder and have it be a book again.....these books never go over about 300 pages .....so i only need 3 number digitsthanks for any help Rob
DigeratiPrime Posted March 11, 2006 Posted March 11, 2006 Ant Renamer > Actions > Enumeration > "Increment by:" > 2http://www.antp.be/software/renamer
Scubar Posted March 11, 2006 Posted March 11, 2006 i just use LupasRename. Works like a charm for both folder and file renaming.
phillyman2004 Posted March 11, 2006 Author Posted March 11, 2006 I just put some more thought into this ......and the program you suggested will only help me with half of my problemIt was 3am when i wrote the original post ....so i wasnt thinking to clearly......anywaysGo get a magazine .....hold it cover facing up .....Those are the odd pagesbook 001.jpgbook 003.jpgbook 005.jpg...Now flip the magazine over and pretend you want to scan the Even pages .......now you need the program to do this book 116.jpgbook 114.jpgbook 112.jpg...To rename the second batch of files .....I basically need a custom batch file that will prompt for the prefix of the file ......then prompt for which page it starts at (example 116) then rename them backwards to 002I really dont feel like flipping each page over to be scanned correctly .....then flip them back to normal for storage
Blub Posted March 11, 2006 Posted March 11, 2006 (edited) Hope this helps. Just modifiy until it suits you. For example you could use set /p for user prompt for names as I understand you'd like from your first post. To change leading zero's modfiy the section after "lead=" to your desired number of leading zero's. Ciao and good luck!@echo offclsset myext=txtset myname=book_set /a c_zero=900set /a step=-50set /a i=0set /a j=0echo new filename : %myname%echo file extension: %ext%echo start counter : %c_zero%echo step : %step%echo:for /f %%F in ( 'dir %progdir% /A:-D /B ^| findstr /i "%ext%" ^| findstr /v /i "%myname%"' ) do ( set FileN=%%F set /a i+=1 call :create )goto :eof:create setlocal ENABLEDELAYEDEXPANSION set /a j=(%i%-1)*%step%+%c_zero% set lead= if %j% lss 1000 set lead=0 if %j% lss 100 set lead=00 if %j% lss 10 set lead=000 echo %FileN% will be copied to %myname%%lead%%j%.%ext% copy %FileN% %myname%%j%.%ext% endlocal Edited March 11, 2006 by Blub
gunsmokingman Posted March 11, 2006 Posted March 11, 2006 This is a VBS script that renames all the files in the folder with the parent path. This uses abrows for dialog so you can run this script from any where.EG If you had a folder on C:\MyTest then all the files would be named C_MyTest_FilenameConst MY_COMPUTER = &H11&,WINDOW_HANDLE = 0, OPTIONS = 0 strComputer = "." Dim RenamF, oShell,Folder, FolderItem Set oShell = CreateObject("Shell.Application") Function ReNameFolderContents Set Folder = oShell.BrowseForFolder(WINDOW_HANDLE, "Select The Folder With The Files To ReName:", OPTIONS, MY_COMPUTER) If Folder Is Nothing Then CreateObject("Wscript.Shell").Popup "User Has Cancel", 4,"User Cancel", 0 + 32 Else Set FolderItem = Folder.Self Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colFileList = objWMIService.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='" & FolderItem.Path & "'} Where ResultClass = CIM_DataFile") For Each objFile In colFileList Rn1 = Replace(objFile.Drive,":","_") : Rn2 = Replace(objFile.Path,"\","_") strNewName = objFile.Drive & objFile.Path & Rn1 & Rn2 & objFile.FileName & "." & objFile.Extension errResult = objFile.Rename(strNewName) Next End If End Function ReNameFolderContents
LLXX Posted March 12, 2006 Posted March 12, 2006 Has the following question ever occurred to any one of you above?He specifies the destination filenames, but what about the source filenames?...how are you going to ensure that the renaming takes place in the intended order?I think an actual program instead of a batch file is in order here.
phillyman2004 Posted March 12, 2006 Author Posted March 12, 2006 Has the following question ever occurred to any one of you above?He specifies the destination filenames, but what about the source filenames?...how are you going to ensure that the renaming takes place in the intended order?I think an actual program instead of a batch file is in order here.I was hoping the program would import in alphabetical order .......book 001.jpg book 002.jpg...Would turn intobook 116.jpgbook 114.jpg...I may be the only person in the world that needs this code It just sucks that the scanner software doesnt anticipate you needing to scan such things .......
Blub Posted March 12, 2006 Posted March 12, 2006 (edited) @LLXX: yes this did occur to me, but since the pages *should* be created in order and numbered incrementally, the batch file *might* just do the trick. Anyway, it's basically part of my batch file that creates the bulk content of RunOnceEx entries for uA install. See if it helps, if not no time wasted. By the way, I don't use RunOnceEx anymore, but even for that one I still did manual editing in the end as of course a program is also best for this. To clarify, the script looks for a file pattern (I used txt in the example here because I made a few files with .txt extension to test it quickly. But it can be modified to use any pattern. Also it excludes certain files (here the newly created files, which means you cannot use the same basic file name or it wouldn't do anything. This exclude list could be extended to ignore anything present you don't want processed.If the source is in random order/has random names, I don't see how it could be done without someone telling which order to use anyway (but usually there is always a way if you try hard enough). But yes, a program would be better yes, much better. I just don't have one I believe the best chance to have it run properly is to scan starting 1 to x uneven in one directory and then x+1 to 2 in reverse order in another. Run the script for the reverse order adjusting start and step -2. This is how I understood your procedure to be?Didn't look at VBS script but presumably either can be made to do the trick under the condition the source files are in some order. Any is ok as long you know what the order is and it stays like that. Edited March 12, 2006 by Blub
gunsmokingman Posted March 12, 2006 Posted March 12, 2006 (edited) Try this sfx file on a test folder it will do nothing but show you the name changes.If it does what you want I will change it to rename the files.Const MY_COMPUTER = &H11&,WINDOW_HANDLE = 0, OPTIONS = 0 : strComputer = "." Dim Act, Fso, RenamF, oShell,Folder, FolderItem, VBS Dim strErrResuts, TheFile, OldName, ReNameFile, CT : CT = 0 Set Act = CreateObject("Wscript.Shell") : Set oShell = CreateObject("Shell.Application") Set Fso = CreateObject("Scripting.FileSystemObject") VBS = Act.ExpandEnvironmentStrings("%Systemdrive%\Rename_FolderContents_v1.vbs") Function ReNameFolderContents Set Folder = oShell.BrowseForFolder(WINDOW_HANDLE, "Select The Folder With The Files To ReName:", OPTIONS, MY_COMPUTER) If Folder Is Nothing Then Act.Popup "User Has Cancel", 4,"User Cancel", 0 + 32 Else Set FolderItem = Folder.Self Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colFileList = objWMIService.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='" & FolderItem.Path & "'} Where ResultClass = CIM_DataFile") For Each objFile In colFileList CT = CT + 1 TheFile = objFile.Drive & objFile.Path & objFile.FileName & "." & objFile.Extension OldName = TheFile & vbCrLf & objFile.FileName & "." & objFile.Extension ReNameFile = objFile.FileName & "-" & CT &"." & objFile.Extension strNewName = ReNameFile '''' UNCOMMENT BELOW TO RENAME ' errResult = objFile.Rename(strNewName) strErrResuts = strErrResuts & vbCrLf & OldName & vbCrLf & strNewName Next Act.Popup "Completed Renaming The Files In:" & vbcrlf & FolderItem.Path, 10,"Finished ReName", 0 + 64 End If End Function ReNameFolderContents Act.Popup "Folder Rename List " & vbCrLf & strErrResuts, 30 ,"Rename List", 0 + 32 If Fso.FileExists(VBS) Then : Fso.DeleteFile(VBS) : End If Edited March 14, 2006 by gunsmokingman
phillyman2004 Posted March 13, 2006 Author Posted March 13, 2006 (edited) Try this sfx file on a test folder it will do nothing but show you the name changes.If it does what you want I will change it to rename the files.Doesnt look like that works .....maybe its something that can be fixed ......in this example Image 0004 should have been renamed to Image 0126.......there are 66 image files .....and counting backwards every other number would be equal to thatAnd if your wondering what i am doing ......I have over 500 videogame magazines .....i am scanning them into electronic format .....rather then deal with the magazines being space hoggers Edited March 13, 2006 by phillyman2004
gunsmokingman Posted March 13, 2006 Posted March 13, 2006 (edited) All you have to do is change this to suit your needs.This start the counter at Zero.CT : CT = 0Then it passes the counter number to the filenameReNameFile = objFile.FileName & "-" & CT &"." & objFile.ExtensionIf you want to count backward from 66 then start the counter at 66 and change thisCT = CT - 1This is a redit code the counter start at 100 and goes backward, see attach image for the name changes.Const MY_COMPUTER = &H11&,WINDOW_HANDLE = 0, OPTIONS = 0 : strComputer = "." Dim Act, Fso, RenamF, oShell,Folder, FolderItem, VBS Dim strErrResuts, TheFile, OldName, ReNameFile, CT : CT = 100 Set Act = CreateObject("Wscript.Shell") : Set oShell = CreateObject("Shell.Application") Set Fso = CreateObject("Scripting.FileSystemObject") VBS = Act.ExpandEnvironmentStrings("%Systemdrive%\Rename_FolderContents_v1.vbs") Function ReNameFolderContents Set Folder = oShell.BrowseForFolder(WINDOW_HANDLE, "Select The Folder With The Files To ReName:", OPTIONS, MY_COMPUTER) If Folder Is Nothing Then Act.Popup "User Has Cancel", 4,"User Cancel", 0 + 32 Else Set FolderItem = Folder.Self Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colFileList = objWMIService.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='" & FolderItem.Path & "'} Where ResultClass = CIM_DataFile") For Each objFile In colFileList CT = CT - 1 TheFile = objFile.Drive & objFile.Path & objFile.FileName & "." & objFile.Extension OldName = TheFile & vbCrLf & objFile.FileName & "." & objFile.Extension' ReNameFile = objFile.FileName & "-" & CT &"." & objFile.Extension ReNameFile = "Book-0" & CT &"." & objFile.Extension strNewName = ReNameFile '''' UNCOMMENT BELOW TO RENAME ' errResult = objFile.Rename(strNewName) strErrResuts = strErrResuts & vbCrLf & OldName & vbCrLf & strNewName Next Act.Popup "Completed Renaming The Files In:" & vbcrlf & FolderItem.Path, 10,"Finished ReName", 0 + 64 End If End Function ReNameFolderContents Act.Popup "Folder Rename List " & vbCrLf & strErrResuts, 30 ,"Rename List", 0 + 32 If Fso.FileExists(VBS) Then : Fso.DeleteFile(VBS) : End If Edited March 14, 2006 by gunsmokingman
phillyman2004 Posted March 13, 2006 Author Posted March 13, 2006 (edited) All you have to do is change this to suit your needs.This start the counter at Zero.CT : CT = 0Then it passes the counter number to the filenameReNameFile = objFile.FileName & "-" & CT &"." & objFile.ExtensionIf you want to count backward from 66 then start the counter at 66 and change thisCT = CT - 1This is a redit code the counter start at 100 and goes backward, see attach image for the name changes.Const MY_COMPUTER = &H11&,WINDOW_HANDLE = 0, OPTIONS = 0 : strComputer = "." Dim Act, Fso, RenamF, oShell,Folder, FolderItem, VBS Dim strErrResuts, TheFile, OldName, ReNameFile, CT : CT = 100 Set Act = CreateObject("Wscript.Shell") : Set oShell = CreateObject("Shell.Application") Set Fso = CreateObject("Scripting.FileSystemObject") VBS = Act.ExpandEnvironmentStrings("%Systemdrive%\Rename_FolderContents_v1.vbs") Function ReNameFolderContents Set Folder = oShell.BrowseForFolder(WINDOW_HANDLE, "Select The Folder With The Files To ReName:", OPTIONS, MY_COMPUTER) If Folder Is Nothing Then Act.Popup "User Has Cancel", 4,"User Cancel", 0 + 32 Else Set FolderItem = Folder.Self Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colFileList = objWMIService.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='" & FolderItem.Path & "'} Where ResultClass = CIM_DataFile") For Each objFile In colFileList CT = CT - 1 TheFile = objFile.Drive & objFile.Path & objFile.FileName & "." & objFile.Extension OldName = TheFile & vbCrLf & objFile.FileName & "." & objFile.Extension' ReNameFile = objFile.FileName & "-" & CT &"." & objFile.Extension ReNameFile = "Book-0" & CT &"." & objFile.Extension strNewName = ReNameFile '''' UNCOMMENT BELOW TO RENAME ' errResult = objFile.Rename(strNewName) strErrResuts = strErrResuts & vbCrLf & OldName & vbCrLf & strNewName Next Act.Popup "Completed Renaming The Files In:" & vbcrlf & FolderItem.Path, 10,"Finished ReName", 0 + 64 End If End Function ReNameFolderContents Act.Popup "Folder Rename List " & vbCrLf & strErrResuts, 30 ,"Rename List", 0 + 32 If Fso.FileExists(VBS) Then : Fso.DeleteFile(VBS) : End IfSo in my example right now there are 66 image files .......the last image should be renamed fromNintendo Power Issue 180 - 0066.jpg to Nintendo Power Issue 180 - 0002.jpgNintendo Power Issue 180 - 0065.jpg to Nintendo Power Issue 180 - 0004.jpgNintendo Power Issue 180 - 0064.jpg to Nintendo Power Issue 180 - 0006.jpgEtc....See .....the images that were scanned ....numerically go in order .....but i need them renamed backwards skipping every other numberRegular renamer programs work fine on the first half of the book .....because all i am doing there is renaming the files and skipping each numberFlipping the book over to scan the Even pages ....results in the magazine being last page up .....which is where my situation comes into playSo basically the program i guess would need to ask for the prefix of what i wanted the file to be namedNintendo Power Issue 180 - Then It would need to know how many image files total?66It would then know the first Image file that it found would be renamed to Nintendo Power Issue 180 - 0132.jpgThen it would move to the next file .....and rename it Nintendo Power Issue 180 - 0130.jpgand so on .....Like i said the Odd pages are no problem because they go in order .....and i can use a standard renamer program with enumeration = 2 and starting at 0001I really do appriciate this help you guys are giving me Rob Edited March 13, 2006 by phillyman2004
phillyman2004 Posted March 13, 2006 Author Posted March 13, 2006 Nevermind......I contacted the guy that designed AntRenamer......the program that was suggested and all i needed to do is click on the sort button so that the last file was at the top ........and rename Problem solved!
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now