Advanced bulk rename tool

I’ve just read about f2.

Check out the examples in the tutorial:

It is EXIF-aware, but can do all sorts of substitutions and use regex capture variables, as well.

Source code: GitHub - ayoisaiah/f2: F2 is a cross-platform command-line tool for batch renaming files and directories quickly and safely. Written in Go!

6 Likes

Neat, but writing a script in any language you know may be quicker than reading even 20% of the manual :wink:

2 Likes

Yes that’s a beast of an app.
I don’t know any scripting and struggle with file manipulation. Can anyone tell me how to rename in Linux like this please -

Suppose I have a folder with nothing in it except a bunch of raw+jpeg pairs of files. Say
IMG_1000.CR2 through IMG_1009.CR2, and 10 more the same except .JPG

I want to rename to
_6D_12345.CR2 through _6D_12354.CR2 and the same range for the JPGs.

So I supply “6D” and “12345” and something just does it. If it makes it easier, assume the “12345” is always 5 digits.

Something like below, but no error checking is done!

 1 #!/bin/sh
  2 
  3 ## Find all IMG_*.CR2 files in current directory and rename them
  4 
  5 [ "$#" != "2" ] && echo "Usage: $0 <subtext> <outindex>" && echo "E.g.: $0 D6 12345" && exit 1
  6 
  7 ## Input subtext, eg D6
  8 subtext=$1
  9 ## Output start index, eg 12345
 10 outindex=$2
 11 
 12 ## Input subtest
 13 inputtext=IMG_
 14 
 15 ## Counter
 16 index=$outindex
 17 
 18 ## Find all input files, sort numerically, rename
 19 ## As is it will print what files will be renamed to what
 20 ## To actually rename remove echo before mv...
 21 for f in `ls *${inputtext}*${inputindex}.CR2 | sort -n`; do
 22     out=_${subtext}_$index.CR2
 23     echo mv $f $out
 24     index=`expr $index + 1`
 25 done

Check in Krename, I use it with Krusader. Makes renaming files easy.

3 Likes

Many thanks @tankist02 , I’ve got this going, learning along the way not to put line nos in a bash file lol; and that the action gets started with a shebang!
It doesn’t do the jpegs but that is a detail, I hardly make any use of the soocs, and I can see how to modify the code to do them if necessary.
Thanks again.

Yeah, adding JPEG processing was left as an exercise :slight_smile:

This is cool @kofa! If I ever need to move awak from exiftool for bulk renaming, I’d go to this.

I think it can be useful independently of its EXUF capability.

Indeed it can, but I don’t really need that apart from photos right now :slight_smile: