* Patrick Shanahan <paka@opensuse.org> [08-28-19 12:49]:
I regularly import photos from a flash drive and rename them with a script to YYMODD_HHMMSS_<orig_file_name>.ext
Sometime recently my script, which I have used successfully for quite a few years, failed me and I cannot determine why.
The script: exiv2 mv \-k \-r %y%m%d_%H%M%S_:basename: \.\/*.{nef,jpg}
exiv2 is a compiled app similar to exiftool, a perl app
directory contents before script: -rwxr-xr-x 1 paka users 57253957 aug 21 16:12 aaa_3410.nef -rwxr-xr-x 1 paka users 56087308 aug 21 16:12 aaa_3411.nef -rwxr-xr-x 1 paka users 54191672 aug 21 16:12 aaa_3412.nef -rwxr-xr-x 1 paka users 54679653 aug 21 16:12 aaa_3413.nef -rwxr-xr-x 1 paka users 59877177 aug 21 16:12 aaa_3414.nef -rwxr-xr-x 1 paka users 59788737 aug 21 16:12 aaa_3415.nef -rwxr-xr-x 1 paka users 58250749 aug 21 16:12 aaa_3416.nef
screen output of the failure:
rename2date -k: Failed to open the file -r: Failed to open the file %y%m%d_%H%M%S_:basename:: Failed to open the file exiv2: File `./20190821_201219.nef' exists. [O]verwrite, [r]ename or [s]kip? ^C
directory contents after script: -rwxr-xr-x 1 paka users 57253957 Aug 21 16:12 20190821_201216.nef -rwxr-xr-x 1 paka users 56087308 Aug 21 16:12 20190821_201217.nef -rwxr-xr-x 1 paka users 54191672 Aug 21 16:12 20190821_201219.nef -rwxr-xr-x 1 paka users 54679653 Aug 21 16:12 aaa_3413.nef -rwxr-xr-x 1 paka users 59877177 Aug 21 16:12 aaa_3414.nef -rwxr-xr-x 1 paka users 59788737 Aug 21 16:12 aaa_3415.nef -rwxr-xr-x 1 paka users 58250749 Aug 21 16:12 aaa_3416.nef
in exiv2 :basename: is the original filename w/o extension
I understand the failure as the script is trying to write the next filename as an existing filename. What I do not understand is why ":basename:" is not being applied. If ":basename:" was being applied there would be no failure as there would be no duplication of filenames.
and I tried escaping, \:basename\:
and after further experimentation, I have found the solution: remove "mv" from the script: exiv2 \-k \-r %y%m%d_%H%M%S_:basename: \.\/*.{nef,jpg} works tks, -- (paka)Patrick Shanahan Plainfield, Indiana, USA @ptilopteri http://en.opensuse.org openSUSE Community Member facebook/ptilopteri Photos: http://wahoo.no-ip.org/piwigo paka @ IRCnet freenode -- To unsubscribe, e-mail: opensuse-support+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-support+owner@opensuse.org