Mobile app version of vmapp.org
Login or Join
Reiling762

: Batch renaming files to match exported file names? I'm importing files into a DAM, both RAW files and edited JPG's. Both file types are supposed to have the same file name, but I've run into

@Reiling762

Posted in: #BatchProcessing

I'm importing files into a DAM, both RAW files and edited JPG's. Both file types are supposed to have the same file name, but I've run into a couple folders where the DNG's have serial file names (IMG_01.dmg, IMG_02.dmg, IMG_03.dmg, etc...), but the edited JPG's were exported with the names of the models as their filenames (FirstLastname_01.jpg, FirstnameLast_02.jpg, LastnameFirstname_03.jpg, etc...) What's fortunate is that the sequence number matches on both the raw and exported filetypes. What I want to know is if there's a way I can use the sequence numbers to batch rename all the raw file types to match the filenames of the jpegs.

Has anyone done anything like this before? Are there any apps that can do this task? I'm hoping to figure out how to do this with Adobe Bridge.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Reiling762

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cugini998

And the operating system is ...?

for file in *dmg
do
nrdmg=${file/*_/}
nr=${nrdmg/.*/}
name=*_$nr.jpg
bn=$(basename $name .jpg);
echo mv $file $bn.dmg
done


If that looks good, remove the "echo".
This will work out of the box on a unixiod system with bash as shell, i.e. Linux, maybe MacOS.

There is a free sh-Implementation for Windows systems too. With WindowsPowderShell or command(32?64?).exe, similar commands should be possible, but I would expect a diffrent syntax.

If your files are in sequence, say from IMG_17.dmg to IMG_49.dmg, it would be even simpler:

for n in {17..49}; do jpg=*$n.jpg ; base=$(basename $jpg .jpg); echo mv IMG_$n.dmg $base.dmg; done


(Again the 'echo' is for first controlling.)

Note that on unixoid systems, the case of the names (JPG/jpg etc.) matters.

Second note: For leading zeros, you have to write them down:

for n in {01..09}; do jpg=*$n.jpg ; base=$(basename $jpg .jpg); echo mv IMG_$n.dmg $base.dmg; done

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme