Page 1 of 1

new file name from source file name

Posted: 2011-03-12T07:43:59-07:00
by Okeebc
Is there a way to use the file name of the source file to name the new file? For instance:

convert freeport.jpg -color 127 (?).png

where (?) is the command to use the source file name, in this case freeport.

Thanks in advance.

Re: new file name from source file name

Posted: 2011-03-12T11:10:41-07:00
by fmw42
try

convert freeport.jpg -set filename:original %t -colors 127 %[filename:original].png

Re: new file name from source file name

Posted: 2011-03-12T19:52:36-07:00
by anthony
See... IM Examples, Saving Images, Filename Escapes.
http://www.imagemagick.org/Usage/files/#save_escapes

NOTE this also provides a way of using convert in a montage type situation. Though convert will always read in all images
into memory, where mogrify handles them one image at a time.
The "convert" alternative to "mogrify"
http://www.imagemagick.org/Usage/basics ... fy_convert

I only added that example a couple of days ago, so it is good timing!

.Just one word of warning, do not include the file suffix in the filename setting! IM will not see it and save it using the original file format, rather than a posibly different one that was set in the in the filename setting.

Re: new file name from source file name

Posted: 2011-03-14T17:41:49-07:00
by Okeebc
Thanks guys! :D