10+ useful code snippets of Linux shell scripts for how-to color, sendmail, log, change dir, parse parameters, loop, configuration file, switch..case and more.
This post has two batch scripts: 1. Batch script to rename files with zero padded number series-prefix 2. Batch script to remove prefix of perticular length 1. Batch script to…
4 responses to “batch script to add remove prefix zero pad bulk file rename”
please help me….i need a batch to delete the sufix “.nusm” from mi files name….can help me please?
I am looking to just rename *.jpg files to a fixed length. They all need to be 7 left of .jpg?
Can your example pad script be modified to do that easily?
Examples:
1234567.jpg ok already.
123456.jpg needs to be 0123456.jpg
And of course they could start with 26.jpg (one or more numbers left of jpg) for example 0000026.jpg
tia.
You may read from and write to a file to remember last file name using batch script.
Create a counter.txt to store the last variable value
As per my script use following line to assign last counter value.
set /p cnt=counter.txt
Consider this:-
Step 1: Create counter.txt in same directory of script.
step 2: Use below script updated to read counter value from a text file and rename from that number.
@echo off
setLocal EnableDelayedExpansion
:: set /a cnt=1counter.txt
set /p cnt=
)
:Set0Pad
set padcntr=0000000000%cnt%
set str=!padcntr:~-%1!
set renstr=%str%
set /a cnt+=1
I need to create an batch file that will
rename a file on my F: drive
named MyBackup 00001.qic
to MyBackup nnnnn.qic (nnnnn = next available file number).
For example if files exist:
MyBackup 00002.qic
MyBackup 00003.qic
MyBackup 00004.qic
MyBackup 00005.qic
then rename MyBackup 00001.qic to MyBackup 00006.qic
Yes, the file names always have a space just before the 5 digit number.
Since I am just learning how to write .bat files for my Windows2000 Computers,
File Renamer