LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-18-2004, 01:34 PM   #1
enygma
Member
 
Registered: Mar 2003
Distribution: CentOS 5.2
Posts: 43

Rep: Reputation: 15
Problems playing with file extensions


Ok, here is the issue. I am trying to write a script that will allow me to convert thousands of images in a directory into a different format. Here is what I am doing so far:
Code:
for i in *png; do convert $i ./jpg/$i.jpg; done
This works great, but the only problem with that is that I get the files renamed as such:

file.png will become file.png.jpg

I had created a revision of this script that will fix that and convert it to file.jpg instead, however, I can't remember the command I used in a certain step. I was hoping someone else here may be able to help me. Basically, it went something like this:
Code:
for i in *png; do convert $i ./jpg/`command $i ".png"`.jpg; done
The only problem is that I can't remember what 'command' was. Basically, what happened was command file.png ".png" echoed back just file. Any ideas?
 
Old 08-18-2004, 01:48 PM   #2
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
Atleast in bash:
Code:
for i in *.png; do convert $i ./jpg/${i/.png/.jpg}; done
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux File Extensions kompact Linux - Newbie 3 04-18-2005 09:15 AM
Need help with File Extensions Linux nooB 454 Linux - Newbie 3 04-10-2005 05:41 PM
File Extensions!!! rejeK Linux - Software 5 12-20-2004 07:30 PM
File Extensions RpgActioN Slackware 1 09-22-2004 10:20 PM
GIMP file extensions Crashed_Again Linux - General 4 02-01-2003 04:05 PM

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

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