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 &引用;“动议/任”;给出语法错误,我可以';t形解_Batch File_Batch Rename - Fatal编程技术网

Batch file &引用;“动议/任”;给出语法错误,我可以';t形解

Batch file &引用;“动议/任”;给出语法错误,我可以';t形解,batch-file,batch-rename,Batch File,Batch Rename,我试图用批处理文件重命名一些文件夹,但我尝试的所有操作都会导致语法错误。以下是我目前的情况: for /d %%a in (%cd%\*.*) do call :moveandrename %%~nxa %%a . . . :moveandrename if exist %2\%1.pdf if exist %2\%1.xml move "%2" "%~dp0\export\_verarbeitet" ren "%~dp0\export\_verarbeitet\%1" "%1_verarbei

我试图用批处理文件重命名一些文件夹,但我尝试的所有操作都会导致语法错误。以下是我目前的情况:

for /d %%a in (%cd%\*.*) do call :moveandrename %%~nxa %%a
.
.
.
:moveandrename
if exist %2\%1.pdf if exist %2\%1.xml move "%2" "%~dp0\export\_verarbeitet"
ren "%~dp0\export\_verarbeitet\%1" "%1_verarbeitet_%date%_%time%"
有什么建议吗?

我发现了错误

将“%time”添加到foldername会导致语法错误,这就是它的工作原理

mkdir export\1
mkdir export\_verarbeitet
rem.>export\1\1.pdf
rem.>export\1\1.xml
for /d %%a in (%~dp0export\*.*) do call :moveandrename %%~nxa %%a
goto :eof
:moveandrename
if exist "%~2\%~1.pdf" if exist "%~2\%~1.xml" move "%2" "%~dp0export\_verarbeitet\"
ren "%~dp0export\_verarbeitet\%1" "%1_verarbeitet_%date%"
pause
goto :eof

路径中是否有空格?请尝试引用文件名,如果传递,请使用
~
删除引号
if exist“%~2\%~1.pdf”if exist“%~2\%~1.xml”
路径中没有空格…路径中有符号?会出现哪种语法错误?请记住,您必须使用goto:eof命令退出sub(movedandrame)。此外,在移动和命名标签之前,您必须添加一个goto:eof,否则,for循环完成后,您将进入此部分。
%date%
%time%
可能包含非法的文件名字符,具体取决于区域设置。最好使用