Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.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 在批处理代码中指定通常与.bat在同一文件夹中工作的目录位置_Batch File - Fatal编程技术网

Batch file 在批处理代码中指定通常与.bat在同一文件夹中工作的目录位置

Batch file 在批处理代码中指定通常与.bat在同一文件夹中工作的目录位置,batch-file,Batch File,如果.bat与文件位于同一个文件夹中,我有这段代码。代码来自: 我想要一个目录,上面的过程可以发生 这是我的代码,但我无法让它工作 %NewFolder% - it is specified in the code above this part. setlocal enabledelayedexpansion set /a count=0 for /f "tokens=*" %%a in ('dir /b /od "004 - Images Ready\%NewFolder%\"*.

如果.bat与文件位于同一个文件夹中,我有这段代码。代码来自:

我想要一个目录,上面的过程可以发生

这是我的代码,但我无法让它工作

%NewFolder% - it is specified in the code above this part. 

   setlocal enabledelayedexpansion
set /a count=0
for /f "tokens=*" %%a in ('dir /b /od "004 - Images Ready\%NewFolder%\"*.JPG') do (
 ren "004 - Images Ready\%NewFolder%\%%a" "004 - Images Ready\%NewFolder%\"!count!.JPG
 set /a count+=1
)

ren
的帮助说明“您不能为目标文件指定新的驱动器或路径”,这意味着目标名称仅限于基本文件名,例如
!计数JPG
@eryksun噢,亲爱的。。。六羟甲基三聚氰胺六甲醚。。可能的解决办法是什么。我有一个bat文件,它位于我希望该过程发生的文件夹之外。感谢您想要
ren“004-图像就绪\%NewFolder%%\%a”!计数JPG
。没有?@eryksun所有文件都在那里。对非常感谢。这个过程只是重命名一个目录中的所有文件,并递增1。bat将不在同一目录中。
for
循环之前推送“004-Images Ready\%NewFolder%\”
,并从
for
循环中删除所有目录内容
popd
for
循环之后
%NewFolder% - it is specified in the code above this part. 

   setlocal enabledelayedexpansion
set /a count=0
for /f "tokens=*" %%a in ('dir /b /od "004 - Images Ready\%NewFolder%\"*.JPG') do (
 ren "004 - Images Ready\%NewFolder%\%%a" "004 - Images Ready\%NewFolder%\"!count!.JPG
 set /a count+=1
)