开发者

For loop recursively through folder in windows cmd for file rename

开发者 https://www.devze.com 2023-02-18 15:51 出处:网络
I\'m trying to iterate through folders with images to create thumbnails using ImageMagic, and rename thumbnail files with small_ prefix.

I'm trying to iterate through folders with images to create thumbnails using ImageMagic, and rename thumbnail files with small_ prefix.

when I execute this in single folder, it works great:

FOR %a in (*.jpg) DO convert %a -thumbnail 30% small_%a

To loop through subfolders, I just need /R flag:

FOR /R %a in (*.jpg) DO convert %a -thu开发者_StackOverflow中文版mbnail 30% small_%a

This will result into new name for thumbnail small_c:\images\image.jpg which is wrong :)

How can I get small_ prefix into file name while recursing through subfolders in script, i.e. from c:\images\image.jpg to c:\images\small_image.jpg ?

Thanks.


I think this is may suit your case.

for /R %i in (*.jpg) DO convert %i -thumbnail 30% %~di%~pi%~ni_small%~xi
0

精彩评论

暂无评论...
验证码 换一张
取 消