【发布时间】:2018-01-12 19:01:53
【问题描述】:
我的一个朋友几年前写了一个批处理脚本。它工作正常,但迁移后突然无法正常工作。我们以oracle形式使用了这段代码。这段代码,将一些文件从源复制到目标,然后检查源和目标中所有文件的大小是否相等,然后让您删除文件。
您能否检查并通知我收到此错误的原因以及如何解决?
此代码生成下一个批处理脚本,它以 Oracle 形式(PL/SQL)编写:
lv_content0 := 'NET USE Z: '||lv_folder;
lv_content1:= 'md '||lv_path; --- what is the content of .bat
lv_content2:= 'start "" "'||lv_path||'"';
--lv_content3:= 'FOR /D %%I in ('|| :CMMT_FIX_MASTER.V_FIX_LOC ||'\*.*) DO move %%I '||lv_path;
lv_content3:= 'XCOPY /H /D /Y /S /E /V /F '|| :CMMT_FIX_MASTER.V_FIX_LOC ||'\*.* '||lv_path;
--13062012 add exception to move folder to patches folder --------
lv_content4a:= '@For /F "tokens=*" %%a IN (' || '''"dir /s /-c "' || :CMMT_FIX_MASTER.V_FIX_LOC || '" | find "bytes" | find /v "free""''' || ') do @Set summaryout1=%%a';
lv_content4b:= '@For /f "tokens=1,2 delims=)" %%a in ("%summaryout1%") do @set filesout1=%%a&set sizeout1=%%b';
lv_content4c:= '@Set sizeout1=%sizeout1:bytes=%' ;
lv_content4d:= '@Set sizeout1=%sizeout1: =%';
lv_content5a:= '@For /F "tokens=*" %%a IN ('|| '''"dir /s /-c "' || lv_path || '" | find "bytes" | find /v "free""''' || ') do @Set summaryout2=%%a';
lv_content5b:= '@For /f "tokens=1,2 delims=)" %%a in ("%summaryout2%") do @set filesout2=%%a&set sizeout2=%%b';
lv_content5c:= '@Set sizeout2=%sizeout2:bytes=%';
lv_content5d:= '@Set sizeout2=%sizeout2: =%';
lv_content6:= '@if %sizeout1% == %sizeout2%' || ' ' || 'RD /S ' || :CMMT_FIX_MASTER.V_FIX_LOC ;
lv_content7:= '@if not %sizeout1% == %sizeout2%' || ' ' || 'echo Folders are not completely sync..Please check !! ' ;
lv_content8:= '@if not %sizeout1% == %sizeout2%' || ' ' || 'pause' ;
这是结果:
NET USE Z: \\ABC\
md \\XXXX\2018\2018-01\10012018\
start "" "\\XXXX\2018\2018-01\10012018\"
XCOPY /H /D /Y /S /E /V /F P:\AAAA\19070\*.* \\XXXX\2018\2018-01\10012018\
@For /F "tokens=*" %%a IN ('"dir /s /-c "P:\AAAA\19070" | find "bytes" | find /v "free""') do @Set summaryout1=%%a
@For /f "tokens=1,2 delims=)" %%a in ("nullummaryout1%") do @set filesout1=%%a&set sizeout1=%%b
@Set sizeout1=nullizeout1:bytes=%
@Set sizeout1=nullizeout1: =%
@For /F "tokens=*" %%a IN ('"dir /s /-c "\\XXXX\2018\2018-01\10012018\" | find "bytes" | find /v "free""') do @Set summaryout2=%%a
@For /f "tokens=1,2 delims=)" %%a in ("nullummaryout2%") do @set filesout2=%%a&set sizeout2=%%b
@Set sizeout2=nullizeout2:bytes=%
@Set sizeout2=nullizeout2: =%
@if nullizeout1% == nullizeout2% RD /S P:\AAAA\19070
@if not nullizeout1% == nullizeout2% echo Folders are not completely sync..Please check !!
@if not nullizeout1% == nullizeout2% pause
EXIT;
错误:
2 File(s) copied
The system cannot find the file nullummaryout1b @Set sizeout1 nullizeout1:bytes @Set sizeout1 nullizeout1: @For /F "tokens=*" %a IN ('"dir /s /-c "\\XXXX\2018\2018-01\10012018\" | find "bytes" | find /v "free""'.
【问题讨论】:
-
请查看minimal reproducible example。源目录中的文件名列表以及进入目标目录的所有文件的名称可能会有所帮助。
-
你用什么参数调用脚本?
-
@jwdonahue:比这更短是不可能的。我编辑了我的问题。请再检查一遍好吗?
标签: batch-file plsql oracle11g windows-10