file renaming with shell script or ?
Hi,
Here's the situation. I use a lot of JPEG images on my website. Before I put each image online, I generate a thumbnail image for each full size image. I do a whole directory of images at a time using imagemagick with a command like: Code:
for img in *.jpg; do convert -resize 144x109 -interlace line -quality 85 $img t$img; done I've yet to find a way to do this with the Linux shell. What I've been doing for now is manually renaming all the files to remove the "t" prefix and add a "_t" suffix to the filename (i.e. timage1.jpg to image1_t.jpg ). Is there a way to automate this process with a shell script or by modifying the shell command above? Or am I crazy to think that there is an easy way to remove the first letter of a filename and insert two letters between the end of the filename and the extension? :confused: Thanks, |
First, read the "convert" man page. I wouldn't be surprised if it did the whole thing without an external loop in the shell.
Yes, you can modify your loop, as follows: Code:
for img in `ls *.jpg | cut -d. -f1`; do This assumes your file names don't contain any periods before ".jpg" |
A couple of renames should work:
rename .jpg _t.jpg t*.jpg will add _t to the end of all the t-prefixed images, for example. . . |
Hi,
Quote:
Thanks! |
Quote:
Thanks, |
Sure: rename t "" * replaces the first "t" with nothing, i.e. deletes it :)
|
All times are GMT -5. The time now is 09:17 AM. |