Skip to main content
Parafox2000
Known Participant
July 27, 2022
Question

Batch Renaming with Adobe Bridge - How to change incrementing numbers "(1)", "(2)" with duplicated

  • July 27, 2022
  • 2 replies
  • 1478 views

I often rename photos with Adobe Bridge but I dont like the fact that it appends an incrementing number in the form of  "(1)", "(2)" etc. - I don't want spaces in my file name and would rather have "_01" or "_1" instead. Is there a way to change that?

This topic has been closed for replies.

2 replies

Participant
July 19, 2023

Here is a bash script that does exactly what you want: replaces ' (n)' with '_n'. Just run it within the directory where all the files are located. Be sure to change the script (call it rename.sh, or whatever) to executable permissions with command: chmod u+x rename.sh

 

#!/bin/bash

shopt -s nullglob
counter=1

for file in *' ('*')'*; do
if [[ $file =~ (.+)\ \(([0-9]+)\)(.+) ]]; then
base_name="${BASH_REMATCH[1]}"
extension="${BASH_REMATCH[3]}"
new_name="${base_name}_$counter$extension"
mv "$file" "$new_name"
((counter++))
fi
done

 

Legend
July 27, 2022

You would need to either avoid duplicated filenames or run another Batch Rename to change the offending characters.

Parafox2000
Known Participant
July 27, 2022

Thanks for the quick response. I sometimes have multiple files taken per second and since my RAW files dont include miliseconds, this template results in duplicate files:

 

"name-"
date: created date (YYYY)
text: "-"
date: created date (MM)
text: "-"
date: created date (DD)
text: "-"
date: created date (HHMMSS)
 
"name-2022-07-22_120925 (1).nef"
"name-2022-07-22_120925 (2).nef"
Legend
July 27, 2022

This is as-designed behavior. You could tack on a line at the end to use a regular expression to get rid of the parentheses and digit if you wanted, or add a serial number.