I use the following command to rename my images:
exiftool -m -r -progress -d "%Y-%m-%d_%H-%M-%S" '-FileName<${DateTimeOriginal}.${SubSectimeOriginal}~~~${Exif:Model;tr/ /_/;s/EOS//;s/910G/910F/;s/PowerShot//;s/DIGITAL //;s/__+/_/g}--${LensID;s/ f\/.*$//;tr/ /_/}%+c.%le' .
The result is: 2017-07-08_12-01-37.99~~~NIKON_D7200--Tamron_AF_16-300mm.nef
I would like to define the extra file information in a bash variable but it is not working:
extra_info="${Exif:Model;tr/ /_/;s/EOS//;s/910G/910F/;s/PowerShot//;s/DIGITAL //;s/__+/_/g}--${LensID;s/ f\/.*$//;tr/ /_/}"
exiftool -m -r -progress -d "%Y-%m-%d_%H-%M-%S" '-FileName<${DateTimeOriginal}.${SubSectimeOriginal}~~~${extra_info}%+c.%le' .
Any ideas?
Try this:
extra_info='${Exif:Model;tr/ /_/;s/EOS//;s/910G/910F/;s/PowerShot//;s/DIGITAL //;s/__+/_/g}--${LensID;s/ f\/.*$//;tr/ /_/}'
exiftool -m -r -progress -d "%Y-%m-%d_%H-%M-%S" '-FileName<${DateTimeOriginal}.${SubSectimeOriginal}~~~'"${extra_info}%+c.%le" .
You want to bash to expand ${extra_info}, so it should be in double quotes. Bash doesn't interpolate within single quotes.
And you don't want bash to expand the ExifTool tag names, so they must be in single quotes.
- Phil
It is working, thanks.