From: Rikishi42 on 28 Jul 2010 17:08 On 2010-07-28, Tuxedo <tuxedo(a)mailinator.com> wrote: > Instead I would like to run a batch procedure to loop through the directory > and move all images into daily named sub-directories based on their file > modification date, so that all images with a same date, such as for example > those dated 16th July 2010 would end up in a sub-directory named > 2010-07-16/ etc. In other words, the shell procedure should create this > sub-directory, move the images with the matching date into it before > proceding with the next batch. Any relevant sub-directories should be > automatically created based on the modification dates found amongst the > images in the present directory, from where for example a 'reorganise.sh' > shell script may be run. > > Perhaps someone has a similar procedure in use already and are willing to > share it? Does it _have_ to be done with a shell script ? The use of the modification date is not very usefull. System dates are not very usefull/reliable for serious filing. After all, a simple 'touch' would change the date, dates can change if you receive or transmit the files using http or ftp, if you happen to move them on an FAT formatted USB stick, etc... I'm using a date from the picture's EXIF information, to file them by image ceation date (scan or photo taken). This information is inside the file and less likely to change. Of course, the EXIF info should be present in the files. The script I use is in Python, and based on their EXIF example script. Point is: do you have Python on your system ? I'm not on the system that script is on, but if you'd like to try it, just give a yell, and I'll find it for you. -- When in doubt, use brute force. -- Ken Thompson
From: Tuxedo on 28 Jul 2010 18:24 Rikishi42 wrote: [...] > Does it _have_ to be done with a shell script ? > > The use of the modification date is not very usefull. System dates are not > very usefull/reliable for serious filing. After all, a simple 'touch' > would change the date, dates can change if you receive or transmit the > files using http or ftp, if you happen to move them on an FAT formatted > USB stick, etc... > > I'm using a date from the picture's EXIF information, to file them by > image ceation date (scan or photo taken). This information is inside the > file and less likely to change. Of course, the EXIF info should be present > in the files. > > > The script I use is in Python, and based on their EXIF example script. > Point is: do you have Python on your system ? > > I'm not on the system that script is on, but if you'd like to try it, just > give a yell, and I'll find it for you. Yes, this sounds great! I'd like to give it a try if you would be so kind to make it available somewhere. Many thanks, Tuxedo
From: Rikishi42 on 28 Jul 2010 19:31 On 2010-07-28, Tuxedo <tuxedo(a)mailinator.com> wrote: >> I'm not on the system that script is on, but if you'd like to try it, just >> give a yell, and I'll find it for you. > > Yes, this sounds great! I'd like to give it a try if you would be so kind > to make it available somewhere. Mind that this is something I had to cobble together real quick to sort out my sister's 4500 pictures in a *very* big hurry for xmas, 2 years ago. It's ugly, but it works. I just had a test run on a batch of pictures. Go to http://www.rikishi42.net/SkunkWorks/Junk/ and take a copy of the 3 files starting with 'exif'. I put them in my ~/bin/ directory. Make'em executable. Right, so try this on a copy first. Say you put your test files in a dir called ~/pics_test/ . cd ~/pics_test find ./ -maxdepth 1 -type f -iname '*.jpg' -exec exif_date.py '{}' ';' It will: - create a dir 'Exif_out' in your dir - create a dir with the date (yyyymmdd) in 'Exif_out' - rename each file to 'yyyymmdd_hhmmss__OriginalPictureName.jpg' and move it into 'Exif_out/yyyymmdd/' - NOT touch files where the Exif date can't be found We can allways change/remove the base dir, subdirs and file names. Just give a yell. Have fun ! -- When in doubt, use brute force. -- Ken Thompson
From: Geoff Clare on 29 Jul 2010 08:43 Rikishi42 wrote: > I'm using a date from the picture's EXIF information, to file them by image > ceation date (scan or photo taken). This information is inside the file and > less likely to change. Of course, the EXIF info should be present in the > files. > > The script I use is in Python, and based on their EXIF example script. You can do the same job with the jhead tool (use the -n option). It should be easily installable on any system (on Debian it's apt-get install jhead). Disclaimer: I often use jhead for other things, but have never used the -n option. I'm assuming it works as described in the man page. -- Geoff Clare <netnews(a)gclare.org.uk>
From: Tuxedo on 30 Jul 2010 08:19 pk wrote: [...] > Something like (assuming you have GNU stat) > > cd /photo/dir > > for f in *.jpg; do > > ymd=$(stat -c %y "$f") > ymd=${ymd%% *} > > if [ ! -d "${ymd}" ]; then > mkdir "${ymd}" > fi > > mv -- "$f" "${ymd}" > > done > Many thanks for this script snipped! I will try it. Tuxedo
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: What is the most portable syntax of these two choices? Next: find command |