LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-26-2006, 05:00 PM   #1
dtcs
LQ Newbie
 
Registered: Jul 2005
Distribution: Slackware, Debian
Posts: 28

Rep: Reputation: 15
Bash script to sort image files


I am trying to write a simple bash script or one line command to basically sort a bunch of .jpg files by date from `identify -verbose` command.
The reason I don't use `ls -l` command to parse date is because the date stamp is incorrect.

Here's what I have:
Code:
identify -verbose *.jpg | awk '/Date Time Original: 2005:02:13 / {print $4}'
How do I change this command to print the file name instead of date?
And how would I pass those files to be copied to other directory?

Thanks in advance.
 
Old 09-26-2006, 06:05 PM   #2
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
hello dtcs. can you post the output of your command? tnx
 
Old 09-26-2006, 06:31 PM   #3
dtcs
LQ Newbie
 
Registered: Jul 2005
Distribution: Slackware, Debian
Posts: 28

Original Poster
Rep: Reputation: 15
it just prints the same date for files that match the expression.
date is the 4th column in that line.

Now I am not that good with awk.
If I want to show the file name, one way of doing it is by calling another expression in awk like /^Image:/ but how do I do that only if first expression is True.
 
Old 09-26-2006, 07:49 PM   #4
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
ok dtcs but i really need a sample output of 'identify -verbose *.jpg' so that i'll know how to modify the statement. can you post them pls? even just for the output of 1 jpeg file. i don't have the 'identify' command btw.
 
Old 09-26-2006, 08:55 PM   #5
dtcs
LQ Newbie
 
Registered: Jul 2005
Distribution: Slackware, Debian
Posts: 28

Original Poster
Rep: Reputation: 15
identify is part of image magick
Code:
2005:02:13
 
Old 09-26-2006, 09:50 PM   #6
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
try this command:
Code:
for a in *.jpg; do
    identify -verbose $a | grep "Date Time Original: 2005:02:13" >/dev/null && {
        echo "found $a"
        cp $a anydir/
    }
done
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash sort files by date in file name thedude2010 Programming 6 05-12-2006 11:07 AM
bash script to sort files by extension otheralex Programming 7 08-19-2005 02:40 AM
bash script to delete files c0d3 Programming 9 12-05-2004 10:45 PM
Bash script to do copying and ISO image creating, etc. satimis Programming 2 09-19-2004 09:47 PM
Image Comparison With Bash Script smcallis Programming 4 06-30-2004 12:53 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:44 AM.

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