Skip to main content
Parafox2000
Known Participant
Jul 27, 2022 11:43 AM UTC
Question

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

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 is closed to new replies. Start a new post to keep the conversation going.

5 replies

Participant
Jul 19, 2023 4:28 PM UTC

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

 

Translate
Legend
Jul 27, 2022 12:37 PM UTC

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

Translate
Parafox2000
Known Participant
Jul 27, 2022 1:22 PM UTC

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"
Translate
Legend
Jul 27, 2022 4:33 PM UTC

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.

Translate