LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 07-11-2005, 03:08 PM   #1
embsupafly
Member
 
Registered: Nov 2002
Location: ARIZONA
Distribution: Ubuntu
Posts: 44

Rep: Reputation: 15
Bash Script Help (ImageMagick)


Hi all!

I need some help with a bash script involving imagemagick. First let me explain what I am trying to accomplish with some background.

I have a directory called phpcars, inside this directory are thousands of directories named 00001, 00002, 00003 and so on. Inside these directories are 2 images (.jpg) and a subdirectory named thumbs. Inside the thumbs directory are the same exact 2 images (.jpg) as the directory above thumbs.

What I need to do is execute this command on all of the images in the subdir "thumbs" of all of the folders within phpcars (00001,00002,00003, ++):

mogrify -resize 160x120 *.jpg

So the script would start off in the phpcars dir, open up the 00001 dir, leave the photos inside this folder alone, open up the thumbs dir, and run the above mogrify command. Then go back to the phpcars dir, and perform the same step for 00002 directory and repeat a few thousand times.

Can anyone assist.
 
Old 07-11-2005, 03:23 PM   #2
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
Code:
for i in dataset
do
  cd $i/thumbs
  mogrify -resize 160x120 *.jpg
  cd ../..
done
... with an appropriate value of `dataset'; try these:
Code:
(1) $(ls -1)
(2) $(seq 1 5000 | xargs printf "%05d ")
(that is, replace `dataset' with one of (1) or (2)).

hth --Jonas
 
Old 07-11-2005, 03:23 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
find -iregex ".*/thumbs/.*\.jpg" -exec mogrify -resize 160x120 {} \;

Should do it - untested.


Cheers,
Tink
 
  


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 script Linh Programming 4 04-21-2004 05:19 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-05-2003 11:58 PM
bash script xscousr Programming 9 07-18-2003 07:34 AM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 05:34 AM

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

All times are GMT -5. The time now is 01:37 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