我正在运行一个 robocopy 脚本,该脚本在过去几周内只是偶尔工作。
目标:将命名方案中的文件复制*Identifier1*到 UNC 路径,然后使用另一个移动它们的应用程序来处理它们。
set sourcefile=D:\some\local\path\here\
set destination=\\someip\some\path\
mkdir %destination%
robocopy %sourcefile% %destination% *Identifier1* /V /R:5 /W:10 >> %Logfile%
wait 60
anotherapplication.exe
Run Code Online (Sandbox Code Playgroud)
*Identifier*在脚本中使用。我收到两个文件,一个被命名$Timestamp_Identifier1.csv,另一个$Timestamp_Identifier2.csv. 我只需要复制其中一份。/V开关以获得更多输出。不幸的是,robocopy 甚至没有提及它在日志中忽略的文件。/R:5和/W:10开关以确保这不是负载问题anotherapplication.exe在同一脚本中运行的 可以很好地拾取文件并且确实能够移动它们。有什么想法或提示吗?一如既往,非常感谢。
Robocopy 偶尔会忽略文件。将命名方案Identifier1中的文件复制到 UNC 路径
您可以尝试使用 Robocopy 添加/FFT开关:
robocopy /FFT %sourcefile% %destination% *Identifier1* /V /R:5 /W:10 >> %Logfile%
Run Code Online (Sandbox Code Playgroud)
/FFT : Assume FAT File Times (2-second date/time granularity).
Run Code Online (Sandbox Code Playgroud)
/FFT 使用 fat 文件计时而不是 NTFS。这意味着粒度有点不太精确。对于跨网络共享操作,这似乎更可靠 - 只是不要依赖文件计时完全精确到秒。
另一个例子
我过去使用过如下所列的类似语法,使用 UNC 路径进行数百GB数据的文件服务器迁移,没有出现任何我无法解决的问题或错误。
考虑使用IF NOT EXIST "%destination%" mkdir "%destination%"仅当目录不存在时才创建该目录。还可以考虑进行递归DIR /S "%sourcefile%\*Identifier1*" >> %LogFile%,将详细信息放入日志中,以显示与命名约定匹配的完整路径和文件名。通过这种方式,您可以在 Robocopy 开始之前查看该命令中的文件是否显示在预期位置,作为确认文件存在的另一个级别。
/ZB :: use restartable mode; if access denied use Backup mode.
Run Code Online (Sandbox Code Playgroud)IF NOT EXIST "%destination%" mkdir "%destination%" DIR /S "%sourcefile%\*Identifier1*" >> %LogFile% robocopy /FFT %sourcefile% %destination% *Identifier1* /ZB /SEC /COPYALL /SECFIX /R:5 /W:5 /LOG+:%LogFile% /V
/IS、/M和/A开关。您可以将XCOPY与/Yand开关一起使用,以在简单的FOR/F循环中使用该方法获得完整日志记录,这似乎也能完全满足您的需要
Run Code Online (Sandbox Code Playgroud)FOR %%A IN ("%sourcefile%\*Identifier1*") DO XCOPY /Y /F "%%~F" "%destination%\">> %Logfile%
| 归档时间: |
|
| 查看次数: |
2115 次 |
| 最近记录: |