Sorting photos into folders based on exif date
I am trying to create a bash script to take photos from a directory, rename and sort them based on the date found in the exif data made by my camera.
When the script is finished it should move all the files into this structure: ./YYYY-MM/YYMMDD-HHMMSS.ext The section I am having trouble with is sorting the renamed files into folders. This command Code:
jhead -autorot -ft -nf%y%m%d-%H%M%S * I am new to scripting as I'm sure you can see, is there an easy way to strip the first four numbers from the file names, and sort them based on that? Code:
#!/bin/sh |
Moin,
you're using bash? Untested: Code:
ls <pathtosortlocation> | while read f; do |
Thank you!
Thanks jan61, that worked perfectly.
Here is my script so far: Code:
#!/bin/bash So I could execute the script as ./ImageSort.sh /new/location/of/images to use /new/location/of/images as the camera path, but if I don't specify an argument it just uses the value given inside? Also, can I have it pause when run, before moving the files to the sort location, and echo $CameraPath for confirmation? Thanks again. |
Moin,
Quote:
Code:
CameraPath=/path/to/default Quote:
Code:
read -p "Path: $CameraPath; continue (y/n)?" confirm |
Moin,
Thanks jan, it's all coming together. I've just found that when using mv to move a directory, it does not merge the folders if the target directory has files inside. Code:
########## Code:
mv: cannot move `/home/angus/.imagesort/0905' to `/home/angus/Photos/0905': Directory not empty |
Finished
All finished.
Code:
#!/bin/bash |
Simplifying
A lot of effort gone into this script but it also also useful to note that jhead as used here can be used to move the photos directly into directories as it renames them by modifying the output string format:
e.g.: jhead -n%Y/%m/%d/%f *.jpg will put the photos into a directory structure of /year/month/day (I used %f to retain the original filename and there are differences between -n and -nf so check the manual). (Also works in "the other os" but you need to use "\" not "/" for directories) |
Quote:
|
All times are GMT -5. The time now is 12:34 AM. |