Page 1 of 1
Problems appending output filenames
Posted: 2010-11-18T14:36:03-07:00
by griffindodd
I'm struggling writing a BAT file in windows to make make new resized images from my source files and have them copied to a new directory with a naming convention...
e.g. a source file of
files\uploads\a.jpg
Needs to be resized and saved to a new directory with a new name, one for a thumbnail and one for a resized version of the image. The resized image needs to append the filename with a suffix 'PICTURE' and the thumbnail needs to append the filename with prefix 'PICTURE' and suffix 'T'...
e.g output looks like this
files\converted\PICTUREa.jpg
files\converted\PICTUREaT.jpg
I have been trying to use MOGRIFY but have been banging my head against a wall trying to work out the renaming.
Any help gladly appreciated.
Re: Problems appending output filenames
Posted: 2010-11-18T14:51:49-07:00
by Bonzo
This should help you out ( in this case I drop the photo over the icon ):
Code: Select all
:: Resize the photo and create a thumbnail
convert.exe %1 -auto-orient ( +clone -thumbnail 500x300 -write "C:\Users\Anthony\Desktop\Rubble_photos\%~n1.jpg" +delete ) -thumbnail 125x75 -unsharp 1.5x1+0.7+0.02 "C:\Users\Anthony\Desktop\Rubble_photos\th_%~n1.jpg"
Re: Problems appending output filenames
Posted: 2010-11-18T15:20:37-07:00
by griffindodd
I had a problem following your code as I trying to write a script I can automate in a bat file, I tried this but I am getting nothing...
set var=folder1
echo %var%
mogrify -thumbnail 600x450 -write "uploads\%var%\%~n1.jpg") -thumbnail 100x100 -unsharp 1.5x1+0.7+0.02 "converted\%var%\THUMB_%~n1.jpg"
Re: Problems appending output filenames
Posted: 2010-11-18T17:21:04-07:00
by fmw42
I know nothing about Windows, but if you have not looked at
http://www.imagemagick.org/Usage/windows/, it could be useful.
Re: Problems appending output filenames
Posted: 2010-11-18T22:04:53-07:00
by anthony
Please, add appropriate line breaks to commands. You can even to this in DOS BAT scripts!!!
Re: Problems appending output filenames
Posted: 2013-09-02T19:58:58-07:00
by Empire
In windows, to save every png image with it's own filename appended with '_red'
Code: Select all
convert ( *.png -alpha extract ) -background red -alpha shape ^
-set filename:f %t_red.%e +adjoin %[filename:f]
More specifically, this changes the images' color to red. Seems like it sets the entire filename to a variable "filename:f". There, %t is the filename text and %e is the extension.
Different from the sources (in Windows), parentheses don't need to be escaped and the source and destination of the output filename don't need to be enclosed in quotes. Also, the ^ character is used for line continuation.
Credit:
Color change -
http://stackoverflow.com/a/14320328/1552045
Output filename -
http://www.imagemagick.org/Usage/files/