LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 11-26-2010, 09:40 PM   #1
adityavpratap
Member
 
Registered: Dec 2004
Location: Hyderabad, India
Distribution: Slackware 13, Ubuntu 12.04
Posts: 440

Rep: Reputation: 32
automatically appending date to filenames of photos imported using shotwell or f-spot


Hi,
Is there a way to automatically append date to the filenames of the photos imported using shotwell or f-spot?
Thanking you,
 
Old 11-27-2010, 09:54 AM   #2
barriehie
Member
 
Registered: Nov 2010
Distribution: Debian Lenny
Posts: 136
Blog Entries: 1

Rep: Reputation: 23
Quote:
Originally Posted by adityavpratap View Post
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!
 
1 members found this post helpful.
Old 11-27-2010, 08:39 PM   #3
adityavpratap
Member
 
Registered: Dec 2004
Location: Hyderabad, India
Distribution: Slackware 13, Ubuntu 12.04
Posts: 440

Original Poster
Rep: Reputation: 32
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.
 
Old 11-27-2010, 09:58 PM   #4
barriehie
Member
 
Registered: Nov 2010
Distribution: Debian Lenny
Posts: 136
Blog Entries: 1

Rep: Reputation: 23
Quote:
Originally Posted by adityavpratap View Post
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.
 
Old 11-27-2010, 10:30 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
"man jhead"
 
Old 11-27-2010, 10:36 PM   #6
adityavpratap
Member
 
Registered: Dec 2004
Location: Hyderabad, India
Distribution: Slackware 13, Ubuntu 12.04
Posts: 440

Original Poster
Rep: Reputation: 32
Hi,
Thanks for the useful information! I have installed exif on my system.

$ exif -t 0x9003 filename.jpg

reveals the 'DateTimeOriginal' information in the following format -

Quote:
EXIF entry 'Date and Time (original)' (0x9003, 'DateTimeOriginal') exists in IFD 'EXIF':
Tag: 0x9003 ('DateTimeOriginal')
Format: 2 ('Ascii')
Components: 20
Size: 20
Value: 2010:11:27 14:35:52
EXIF entry 'Date and Time (original)' (0x9003, 'DateTimeOriginal') exists in IFD 'EXIF':
Tag: 0x9003 ('DateTimeOriginal')
Format: 2 ('Ascii')
Components: 20
Size: 20
Value: 2010:11:27 14:35:52

I am interested in the last line - Value : 2010:11:27 14:35:52

Is there a way I can extract it?

Thanking in advance,
 
Old 11-28-2010, 12:09 AM   #7
adityavpratap
Member
 
Registered: Dec 2004
Location: Hyderabad, India
Distribution: Slackware 13, Ubuntu 12.04
Posts: 440

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by syg00 View Post
"man jhead"
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 {} \;

the files are not being renamed.
 
Old 11-29-2010, 05:39 AM   #8
adityavpratap
Member
 
Registered: Dec 2004
Location: Hyderabad, India
Distribution: Slackware 13, Ubuntu 12.04
Posts: 440

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by adityavpratap View Post
Thanks for directing me to jhead. But there is a small problem. If I issue the following command -



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 {} \;
the files are not being renamed.

Ok, I was able to overcome this problem by using -nf instead of simply -n. Thanks!
 
Old 12-30-2010, 05:54 AM   #9
aidan.whitehouse
LQ Newbie
 
Registered: Dec 2010
Posts: 1

Rep: Reputation: 0
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.
 
Old 12-30-2010, 06:17 AM   #10
adityavpratap
Member
 
Registered: Dec 2004
Location: Hyderabad, India
Distribution: Slackware 13, Ubuntu 12.04
Posts: 440

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by aidan.whitehouse View Post
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 -
Code:
find $SRCD -type f \( -name "*\.jpg" -o -name "*\.JPG" \) -exec jhead -nf%f-%d%m%Y {} \;
should I replace -nf with -ft ?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Shotwell 0.7.2 Released, How to Install Shotwell 0.7.2 in Ubuntu Lucid, Maverick LXer Syndicated Linux News 0 09-11-2010 11:51 PM
LXer: Meet Shotwell - The F-Spot Replacement For Ubuntu 10.10 "Maverick Meerkat" LXer Syndicated Linux News 0 06-13-2010 05:11 PM
can't edit photos in F-Spot balsam Linux - Software 5 01-12-2010 11:53 PM
LXer: Manage Photos with Shotwell LXer Syndicated Linux News 0 11-17-2009 05:50 AM
LXer: Bringing your photos from F-Spot to the Web LXer Syndicated Linux News 0 05-03-2008 01:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration