Batch file Renaming Help
|
Original Message
|
Name: pball
Date: October 8, 2007 at 14:19:37 Pacific
Subject: Batch file Renaming HelpOS: XP ProCPU/Ram: 1 gigModel/Manufacturer: homemade |
Comment: First off could someone help me by explaining some of the basics of renaming in a batch file. Such as how to rename all files in a folder to something_# with # being a growing number. I don't understand the variables and other parts used to do this. Also how could you rename the files in a folder to the folder name plus a number and be able to skip files that are already named that way and continue with the next "unused" name. Such as folder_001.jpg exists and the next file will be named folder_002.jpg so the first file is left unchanged. I ask this since i get new files to add to the folder and wish to leave the older ones named the same.
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Mechanix2Go
Date: October 9, 2007 at 01:58:28 Pacific
|
Reply: (edit)@echo off setLocal EnableDelayedExpansion for /f "tokens=* delims= " %%a in ('dir/b/a-d *.jpg') do ( set /a N+=1 echo %%a | find "_" > nul if errorlevel 1 ren %%a %%~Na_!N!.jpg )
===================================== If at first you don't succeed, you're about average.M2
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: pball
Date: October 9, 2007 at 12:47:38 Pacific
|
Reply: (edit)I tried that and played with it a bit and it didn't do exactly what I'd like. I believe to get what I want the script would have to check if there are properly named files first then rename improperly named files. I have folders that have files in them like this \foldera foldera_001.ext foldera_002.ext foldera_003.ext Then over time I add new randomly named files such as 874855947347.ext 234534565476.ext 234690844890.ext I'd like the first files to remain unchanged while renaming the random files to foldera_004.ext foldera_005.ext foldera_006.ext Would it be to complicated to make a batch file that can do that. Or has anyone ever heard of a program that will rename like this easily, since I've never found one.
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: Mechanix2Go
Date: October 9, 2007 at 13:54:17 Pacific
|
Reply: (edit)It could get pretty hairy in a batch file. Not least because numbers with leading zeros are seen as octal. I use a picture viewer/adjuster called ThumbsPlus [shareware] which does just what you want. ===================================== If at first you don't succeed, you're about average.M2
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: