[SOLVED] automatically appending date to filenames of photos imported using shotwell or f-spot
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi,
Is there a way to automatically append date to the filenames of the photos imported using shotwell or f-spot?
Thanking you,
This works. It takes name.jpg and renames to name-mmddyy.jpg:
Code:
#!/bin/bash
#
# Script by BH
#
ls -1 *.jpg | while read line
do
echo $line | gawk '{ if($0) {sub(/\.jpg/, "", $0); print $0 }}' | while read newname
do
mv $newname.jpg $newname-$(date +%m%d%y).jpg
done
done
exit 0
Must be in the directory you have the files in. If the file extension is not 'jpg' then edit the red text. I'm sure someone can come up with a sed one liner but that's not me!
Hi,
Thanks for the script! :-)
So each time I import the photos, I should run the script. I mean, the script will append the date on which the script was run. So if the snaps were taken on, say 25th of Nov, and imported on the 28th, then the script will append the date 28th. This is not what I want. Is there a way the script extracts the date from EXIM data and appends it to the file-name? Or is there any Graphics software that does it? This way I will be able to catalog the files chronologically.
Hi,
Thanks for the script! :-)
So each time I import the photos, I should run the script. I mean, the script will append the date on which the script was run. So if the snaps were taken on, say 25th of Nov, and imported on the 28th, then the script will append the date 28th. This is not what I want. Is there a way the script extracts the date from EXIM data and appends it to the file-name? Or is there any Graphics software that does it? This way I will be able to catalog the files chronologically.
That script will put the date that the script is run onto the filename. There's a package, exif, that can read/modify that data. Search your available packages for keyword exif and see what's available.
Thanks for directing me to jhead. But there is a small problem. If I issue the following command -
Quote:
$ jhead -n%f-%d%m%Y *.jpg
all the files are appropriately renamed. However if I try to rename all the files including those in sub-directories as -
[QUOTE]$ find . -name "*\.jpg" -exec jhead -n%f-%d%m%Y {} \;
Remember also the -ft option with jhead that will set the file modified datestamp to be the same as what is in the EXIF data. This makes it usable in file management applications like nautilus without renaming. I have a script that runs hourly to do this and also physically rotate pictures so that (predominantly Windows) applications that are too lazy to read this EXIF tag can view the images correctly. This solution may be a little more elegant, depending on what you want to achieve.
Remember also the -ft option with jhead that will set the file modified datestamp to be the same as what is in the EXIF data. This makes it usable in file management applications like nautilus without renaming. I have a script that runs hourly to do this and also physically rotate pictures so that (predominantly Windows) applications that are too lazy to read this EXIF tag can view the images correctly. This solution may be a little more elegant, depending on what you want to achieve.
Thanks for your valuable input! The operative part of my script is -
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.