
On 1 May 2017 at 20:18, Mark Trickett via luv-main <luv-main@luv.asn.au> wrote:
hello All,
I have photos from my mobile phone, an old Nokia 6021, and readily get them onto the PC. The problem is the naming, the first eight characters are the date, two digits for the day, two for the month then four for the year. I wish to reorder them to be year, month and then day. That portion of the filename is then followed by brackets with a three digit sequence number for the second and subsequent photos on the day. it would be good to add the brackets with three zeros when not present. That is followed by a period and the jpg extension.
This will let me order by date when viewing in Image Viewer, and a relatively sane sorting of the filenames. There are something over 450 images in the directory that I wish to edit the names of, so better to get the PC to do the repetitive work.
My shell programming, and the like, are rusty, what there is of such skills. I would appreciate some assistance and pointers.
It is possible but somewhat fiddly to do this as a shell script. Personally I would not solve it that way even though I am comfortable with shell scripting. I recommend the perl rename tool. On debian you would install this package: https://packages.debian.org/jessie/rename This package contains a 'rename' command that accepts perl syntax and applies it to matching filenames. Your specification is mostly clear but does contains some ambiguity, for example: - "brackets", are they () or [] or {} ? - what "sequence number" does the second photo have? - is the "sequence number" inside a pair of brackets? To avoid this game of questions, it would help if you provide actual examples of the various before and after filenames, so that anyone tempted to offer any solution can see and test exactly the names you have, and want.