[opensuse-support] bash script problem
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\: 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
* 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
On Wed, Aug 28, 2019 at 12:49:51PM -0400, Patrick Shanahan wrote:
I regularly import photos from a flash drive and rename them with a script to YYMODD_HHMMSS_<orig_file_name>.ext
https://xkcd.com/1179 ;) (also as https://imgs.xkcd.com/comics/iso_8601.png) Daniel -- To unsubscribe, e-mail: opensuse-support+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-support+owner@opensuse.org
Daniel Morris composed on 2019-08-29 08:55 (UTC+0100):
ROFLOL -- Evolution as taught in public schools is religion, not science. Team OS/2 ** Reg. Linux User #211409 ** a11y rocks! Felix Miata *** http://fm.no-ip.com/ -- To unsubscribe, e-mail: opensuse-support+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-support+owner@opensuse.org
Le 29/08/2019 à 09:55, Daniel Morris a écrit :
On Wed, Aug 28, 2019 at 12:49:51PM -0400, Patrick Shanahan wrote:
I regularly import photos from a flash drive and rename them with a script to YYMODD_HHMMSS_<orig_file_name>.ext
(also as https://imgs.xkcd.com/comics/iso_8601.png)
Daniel
however, almost no camera maker do use this format$ IMG_20190413_120334233_BURST002 (my phone) and why use "-"? the sheme of the OP seems perfect to me jdd -- http://dodin.org -- To unsubscribe, e-mail: opensuse-support+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-support+owner@opensuse.org
On Thu, Aug 29, 2019 at 10:41:28AM +0200, jdd@dodin.org wrote:
Le 29/08/2019 à 09:55, Daniel Morris a écrit :
On Wed, Aug 28, 2019 at 12:49:51PM -0400, Patrick Shanahan wrote:
I regularly import photos from a flash drive and rename them with a script to YYMODD_HHMMSS_<orig_file_name>.ext
(also as https://imgs.xkcd.com/comics/iso_8601.png)
Daniel
however, almost no camera maker do use this format$
IMG_20190413_120334233_BURST002
(my phone)
They also used to prefer proprietary, non-interoperable, and badly documented image formats <sarcasm> but just look how quickly they've progressed in ~30 years </sarcasm>.
and why use "-"? the sheme of the OP seems perfect to me
Don't overlook the winky and the spirit that the help was offered in (after his problem had already been solved). But, OP had 2 digits for year for a conversion he was choosing himself, forming good habits is a good thing, and if you ever have to read YYYYMMDD in a non-fixed space font (like some of the cool kids like to use nowadays) then the two extra characters can really help in discerning between year, month and day fields. Two "extra" characters might be a lot on a diddy screen, but I still ponder how much of the DOS 8.3 filenaming convention constrains us in systems that always had magic numbers and long filenames. Daniel -- To unsubscribe, e-mail: opensuse-support+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-support+owner@opensuse.org
On 29/08/2019 09.55, Daniel Morris wrote:
On Wed, Aug 28, 2019 at 12:49:51PM -0400, Patrick Shanahan wrote:
I regularly import photos from a flash drive and rename them with a script to YYMODD_HHMMSS_<orig_file_name>.ext
Which automatically sorts by date, too :-) -- Cheers / Saludos, Carlos E. R. (from 15.0 x86_64 at Telcontar)
participants (5)
-
Carlos E. R.
-
Daniel Morris
-
Felix Miata
-
jdd@dodin.org
-
Patrick Shanahan