Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 转换到另一个文件夹_Batch File_Cmd_Imagemagick_Image Manipulation_Imagemagick Convert - Fatal编程技术网

Batch file 转换到另一个文件夹

Batch file 转换到另一个文件夹,batch-file,cmd,imagemagick,image-manipulation,imagemagick-convert,Batch File,Cmd,Imagemagick,Image Manipulation,Imagemagick Convert,此命令适用于我: To run from cmd.exe: convert *.jpg -set filename:f "%t.%e" "%[filename:f].png" The same, to run from bat-file (double % instead of single): convert *.jpg -set filename:f "%%t.%%e" "%%[filename:f].png" 现在,假设我有这个文件层次结构: test\ |-- small\

此命令适用于我:

To run from cmd.exe:
convert *.jpg -set filename:f "%t.%e" "%[filename:f].png"

The same, to run from bat-file (double % instead of single):
convert *.jpg -set filename:f "%%t.%%e" "%%[filename:f].png"
现在,假设我有这个文件层次结构:

test\
 |-- small\               <-- this is an empty folder
 |-- image1.jpg
 |-- image2.jpg

我尝试使用,但目前运气不佳。

我想我理解,但请在尝试之前进行备份:

mogrify -path small -format png *.jpg
我没有现成的Windows可供测试,但根据您的评论,请尝试:

convert *.jpg -set filename:f "%%t.%%e" "small/%%[filename:f].png"

马克,谢谢你。目前我正在尝试使用
convert
而不是
mogrify
来避免文件名冲突,如下所述:我已经更新了我的答案,请再看一看。您可能需要在Windows上使用反斜杠,或在斜杠之前使用插入符号(
^
)。不确定您的文件名是否会发生冲突,因为您的所有文件都来自同一目录,因此它们必须是唯一的。是的,使用反斜杠,但不起作用。我很早就尝试过类似的方法,没有luckI,只是在VirtualBox中运行了一个Windows XP,并且命令与我的答案中给出的完全一样,可以很好地工作……尝试发布不工作的脚本。
convert *.jpg -set filename:f "%%t.%%e" "small/%%[filename:f].png"