LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 03-15-2010, 06:28 PM   #1
Daravon
Member
 
Registered: Mar 2006
Posts: 170

Rep: Reputation: 15
Simple scripting help


I use convert and mogrify to convert and mogrify images all the time. The syntax is

Code:
convert pic.jpg newoutputfilename.png
What I want to do is take a whole directory full of tiffs, and convert them to jpgs, with the same filename except for the .xyz. In order to do this, I think I need to do a "foreach".

I've done scripts like this before:
Code:
for pic in `ls *.jpg`; 
do mogrify -modulate 100,0  -normalize -unsharp 15 -fuzz 50% -trim $pic; 
done;
And it has been known to work. But how can I use this with convert? It seems that I need to somehow subtract "jpg" from each filename and append "tif" to form the new output filename, but I don't know how to manipulate strings with bash.
 
Old 03-15-2010, 08:40 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
The 2nd example here http://linux.die.net/man/1/basename gives you the filename sans extension
 
Old 03-15-2010, 10:05 PM   #3
penguiniator
Member
 
Registered: Feb 2004
Location: Olympia, WA
Distribution: SolydK
Posts: 442
Blog Entries: 3

Rep: Reputation: 60
Assuming pic is your control variable and bash is your shell:
Code:
${pic/%jpg/tif} or ${pic%.*}.tif
 
  


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
Need help with simple scripting greengrocer Linux - Newbie 7 06-01-2009 06:02 AM
Simple Scripting Help hopspitfire Linux - General 2 06-12-2007 04:46 PM
simple scripting help please kb100 Programming 7 08-23-2006 06:31 AM
simple scripting help please kb100 Programming 12 08-18-2006 08:34 AM
simple scripting help please kb100 Programming 3 08-18-2006 08:08 AM

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

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