ImageMagick: convert to keep same name for converted image
Solution 1
Use the -set
and formatting options.
convert *.psd -set filename:base "%[basename]" "%[filename:base].png"
See "Long Form Attribute Percent Escapes" and "Filename Percent Escapes" docs.
Update
The mogrify utility that ships with imagemagick can also be used.
mogrify -format png *.psd
Note: Be careful with mogrify as the docs state...
This tool is similiar to convert except that the original image file is overwritten (unless you change the file suffix with the -format option) with any changes you request.
Solution 2
Or, even simpler:
mogrify -format png *.psd
Solution 3
If you are on Linux, Unix or Mac OSX, you could use in a terminal window with Bash shell:
for i in *.psd; do
convert $i ${i/.psd/.png}
done
I deliberately do not advertise mogrify
any more. It is too dangerous for every user who doesn't know it already, and who comes to this website to ask for help. mogrify
is overwriting your original files in some cases (of course not when converting PSD->PNG)
Solution 4
I like the top answer,
that being said, in later versions of ImageMagick, the command is
convert *.psd -set filename:basename "%[basename]" "%[filename:basename].png"
as also mentioned by @jan-glx and @jomel imperio
PaolaJ.
Updated on December 28, 2020Comments
-
PaolaJ. over 3 years
I am converting .psd to .png files inside folder with one. How to keep same name of every file in folder with different extension ?
For example I enter in folder images and then from terminal I execute
$ convert *.psd *.png
but it gives names to .png just numbers not the same as appropriate .psd image.
-
emcconville over 9 yearsThat's right, mogrify with
-format
will do the same thing. -
Jomel Imperio about 6 yearsJust an update:
base
is now calledbasename
. With that substitution, works as expected! -
jan-glx almost 6 years->
convert *.psd -set filename:base "%[basename]" "%[filename:base].png"
-
Mark Setchell almost 4 yearsNote that at v7 of ImageMagick, that becomes
magick mogrify -format png *.psd
-
Eskel about 3 years@MarkSetchell thanks, that works. Is there a way to place the output into a subfolder? Can't figure it out.
-
Mark Setchell about 3 years@Eskel Yes.
mkdir OUTPUT; magick mogrify -path OUTPUT -format png *.psd
-
Salem almost 3 years
mogrify -format png *.psd
works as the best, BTW you can add is as Action onThunar
file mangermogrify -format png %F