
On Mon, 1 May 2017 08:18:03 PM Mark Trickett via luv-main wrote:
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.
for n in ????????*jpg ; do DATE=$(echo $n|cut -c 5-8)$(echo $n|cut -c 3-4)$(echo $n|cut -c 1-2 echo touch -t${DATE}0000 $n echo mv -i $n new/)${DATE}$(echo $n|cut -c 9-80) done The above MIGHT do what you want. Note that I have it "echo" the commands not run them. So paste the above in the shell and see if the mv commands are to your liking. Also note that it's moving files to a directory named "new" to avoid double-processing. The touch command sets the correct date so you can sort it by date as well. Also you could expand that touch command to convert the 3 digit number of photos per day to hours and minutes if you want to have a strict date order work. Naturally this will start a contest of writing the best shell code to solve your problem. ;) -- My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/