在 Imagemagick for linux 中如何对目录进行批量转换
我希望能够指定扫描位置和转换后文件的位置。
只是有很多转换,我有一个脚本可以为我进行排序。 目前我已经尝试过
convert -resize 300x300 > /media/usbdisk1/development/ephoto/richard/images/gallery/2007/29/normal/*.jpg /media/usbdisk1/development/ephoto/richard/images/gallery/2007/29/tn_med/$1.jpg
并且
for i in $( ls /media/usbdisk1/development/ephoto/richard/images/gallery/2007/29/normal); do /usr/convert resize 360x360 > /media/usbdisk1/development/ephoto/richard/images/gallery/2007/29/normal/$i /media/usbdisk1/development/ephoto/richard/images/gallery/2007/29/tn_med/$i done;
I want to be able to specify the location in both where to scan and where the converted file will go.
It's just there is a lot of conversions and I've got a script which should sort it for me.
Currently I've tried
convert -resize 300x300 > /media/usbdisk1/development/ephoto/richard/images/gallery/2007/29/normal/*.jpg /media/usbdisk1/development/ephoto/richard/images/gallery/2007/29/tn_med/$1.jpg
and
for i in $( ls /media/usbdisk1/development/ephoto/richard/images/gallery/2007/29/normal); do /usr/convert resize 360x360 > /media/usbdisk1/development/ephoto/richard/images/gallery/2007/29/normal/$i /media/usbdisk1/development/ephoto/richard/images/gallery/2007/29/tn_med/$i done;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
知道了!
got it!
正如评论所建议的,您可以使用
find
命令:通过使用
-print0
和 xarg 的-0
选项,这还可以处理带有空格和其他内容的文件名奇怪的字符。As comments suggested, you can use the
find
command:By using
-print0
and xarg's-0
option, this also handles filenames with spaces and other odd characters.没有理由将长目录重复三遍。使用变量作为基数。并且不要使用
ls
:您可以这样做,而不是
basename
:There's no reason to repeat your long directory three times. Use a variable for the base. And don't use
ls
:Instead of
basename
you could do it this way: