LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Problems playing with file extensions (https://www.linuxquestions.org/questions/linux-general-1/problems-playing-with-file-extensions-219332/)

enygma 08-18-2004 01:34 PM

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?

ToniT 08-18-2004 01:48 PM

Atleast in bash:
Code:

for i in *.png; do convert $i ./jpg/${i/.png/.jpg}; done


All times are GMT -5. The time now is 03:18 PM.