ImageMagick: convert to keep same name for converted image

蹲街弑〆低调 提交于 2019-11-30 04:31:53

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.

Or, even simpler:

mogrify -format png *.psd

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)

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!