Batch file 如果没有错误,如何让批处理脚本移动文件
我有这样一段代码,只有当.py没有抛出错误,并且它只是将文件保留在原位时,我才尝试移动文件。这对我不起作用,我也不知道为什么。非常感谢您的帮助。无需检查文件是否存在。如果文件不存在,FOR命令将不会迭代该文件。@Squashman这是一个批处理脚本,目前正在生产中,我只是尝试使用Batch file 如果没有错误,如何让批处理脚本移动文件,batch-file,errorlevel,Batch File,Errorlevel,我有这样一段代码,只有当.py没有抛出错误,并且它只是将文件保留在原位时,我才尝试移动文件。这对我不起作用,我也不知道为什么。非常感谢您的帮助。无需检查文件是否存在。如果文件不存在,FOR命令将不会迭代该文件。@Squashman这是一个批处理脚本,目前正在生产中,我只是尝试使用%ERRORLEVEL%变量添加异常处理,以跳过任何出错的文件。最简单的解决方案是使用条件执行script.py在此发布参数列表并移动%%f:\Translated\DocsForPOST\archive。对于错误级别,
%ERRORLEVEL%
变量添加异常处理,以跳过任何出错的文件。最简单的解决方案是使用条件执行script.py在此发布参数列表并移动%%f:\Translated\DocsForPOST\archive
。对于错误级别,不使用变量形式如何?例如:第1行<代码>@对于%%G In(“F:\Translated\DocsForPOST\*.json”)Do@(python.exe“script.py”在这里发布参数列表,我假设“%%~fG”,第2行:如果不是错误级别1 Move/Y”%%~fG“%%~dpGarchive”)
@Compo让我更接近了一点!非常感谢,非常感谢!
cd /d F:\Translated\DocsForPOST
for %%f in (*.json) do (
if exist %%f (
script.py POST list of params here
)
IF %ERRORLEVEL% EQU 0 (
move %%f F:\Translated\DocsForPOST\archive
)
)