LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-25-2007, 02:24 PM   #1
pacaman
LQ Newbie
 
Registered: Feb 2007
Posts: 4

Rep: Reputation: 0
shell script: picture categorize


hey all, my wish is little script from you...

I have tons of pictures by taken digital camera in a directory and sub directories. That script must look at picture's exif data, create directory (directory name must be its taken date) and copy in.

I love linux's file system and shell power. Im sure my wish is very simple for linux.

thx...
 
Old 02-25-2007, 02:37 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
we aren't here to do your work for you mate. you can look at tools like jhead to extract exif header information and i'm sure you'll be fine once you get started.
 
Old 02-25-2007, 02:41 PM   #3
pacaman
LQ Newbie
 
Registered: Feb 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Thank you mate, allready im on jhead but i didn't understand other to dos... will search in uncle google
 
Old 02-25-2007, 02:44 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
don't get me wrong, if you need specifi tips and pointers we're glad to help, but we aren't just going to blindly write an entire script for you on demand, you know?
 
Old 02-25-2007, 03:49 PM   #5
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
What about jhead is confusing?

Here's a sample run on my machine:
Code:
$ ./jhead EL-1997-00031.jpeg
File name    : EL-1997-00031.jpeg
File size    : 16780 bytes
File date    : 2006:06:06 18:51:10
Resolution   : 544 x 434
Comment      :   Imported from PNM image: EL-1997-00031.tmp.pnm
So the next step would be to pipe the output through grep. Something like:
Code:
$ ./jhead EL-1997-00031.jpeg | grep "File date"
File date    : 2006:06:06 18:51:10
Then you'd probably pipe that through cut, awk, or sed, and perhaps other tools to get a date format you like. Then create the directory and mv it there.

To save the output of a command (or series of piped commands) in a script, you would do something like this:
Code:
raw_header_date=$( jhead EL-1997-00031.jpeg | grep "File Date" | cut -c 16-25 )
That ought to be more than enough to get started

Last edited by Dark_Helmet; 02-25-2007 at 03:52 PM.
 
Old 12-31-2008, 09:34 AM   #6
kscott121
Member
 
Registered: Jul 2003
Location: NC
Distribution: Fedora,Mepis,Debian
Posts: 84

Rep: Reputation: 15
Here is a little script that does similar...

Code:
#!/bin/sh
# Will sort all *.jpg files in the current directory.  Then will create 
# directories based on EXIF creation date (YYYYMMDD).  Then move files 
# into these directories and rename the files to the EXIF creation time (HHMMSS).
# Lastly will reset the file creation timestamp to match the EXIF data.
for file in *.jpg; do
    if [ -f "$file" ]; then
    mystring=`exif -t 0x9003 "$file" | grep Value| sed 's/  Value: //' | sed 's/://g'`
    dir=`echo $mystring | awk '{print $1}'`
    ffile=`echo $mystring | awk '{print $2}'`
    tstamp=$dir${ffile:0:4}.${ffile:4:2}

    if [ ! -d "$dir" ]; then mkdir "$dir"; fi
    mv -i "$file" "$dir/$ffile.jpg"
    touch -t $tstamp $dir/$ffile.jpg          #timestamp new jpg file
    fi
done
 
Old 12-31-2008, 01:11 PM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
please don't drag up dead threads. thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 03:14 AM
Script to find all picture files on a HDD and move them scoops98 Linux - General 8 02-27-2007 03:40 AM
I made a shortcut to a shell script and it is using default shell icon... shlinux Linux - Software 2 04-20-2006 07:29 AM
Alias or shell script to confirm 'exit' commands from a shell rose_bud4201 Programming 2 03-08-2006 03:34 PM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 06:32 PM


All times are GMT -5. The time now is 04:54 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration