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.
Problems appending output filenames
Re: Problems appending output filenames
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
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"
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"
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Problems appending output filenames
I know nothing about Windows, but if you have not looked at http://www.imagemagick.org/Usage/windows/, it could be useful.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Problems appending output filenames
Please, add appropriate line breaks to commands. You can even to this in DOS BAT scripts!!!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Problems appending output filenames
In windows, to save every png image with it's own filename appended with '_red'
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/
Code: Select all
convert ( *.png -alpha extract ) -background red -alpha shape ^
-set filename:f %t_red.%e +adjoin %[filename:f]
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/