The photos of my cameras (.CR2
or .JPG
) have correct exif date + time but only in seconds, unfortunately not in milliseconds. Therefore some photos have the same date_time value (shot at the same second).
The photos are saved in sub-folders which is why creating unique filenames (beyond all folders) just by date_time is not possible with exiv2.
Initial situation example:
Folder 1 / 2016_12_01_1326.JPG
Folder 1 / 2016_12_02_1830.CR2
Folder 2 / 2016_12_01_1326.JPG (same date, hours, and seconds but not milliseconds)
I would like to create symbolic links with unique name for all of my photos. My idea for solving this problem is by converting the filenames of the photos to date-time with exiv4 and the symbolic links with the same name plus an ongoing number.
So finally the result of the symbolic links should be for example:
2016_12_01_1326_0001.JPG
2016_12_01_1326_0002.JPG
2016_12_02_1830_0003.CR2
My approach is the following but it doesn't work with the ongoing number:
f=$(pwd);
export f;
var=0; export var;
find 2016/. \( -name "*.CR2" -o -name "*.JPG" \) -execdir sh -c 'ln -s "$PWD"/$(basename {}) "$f"/2016_Links/Pictures/Link_"$((var++))"_$(basename {})' {} \;
The $((var++))
is not working due to the following error:
./20160312_09_02_42.CR2: 1: ./20160312_09_02_42.CR2: arithmetic expression: expecting primary: "var++"
f
defined so that it can be referenced with$f
? – Zanna Dec 20 '16 at 11:30arithmetic expression: expecting primary: "var++"
is almost certainly because yoursh
is notbash
, and does not support the((var++))
arithmetic syntax – steeldriver Dec 20 '16 at 13:12