在 Windows 上“触摸”文件有一种非常简单(尽管晦涩难懂)的语法。(更新最后修改的时间戳)
如果文件在当前目录中,您只需要:
copy /b fileName+
如果文件位于其他路径中,则此方法有效:
copy /b somePath\fileName+,, somePath\
但是,您似乎仍然需要进行大量编码,因为我相信您只想触摸已复制的文件。
以下内容未经测试,但我相信它会起作用。我不能保证表演。此解决方案需要 2 个未使用的驱动器号。我假设 K: 和 L: 可用。
@echo off
:: map unused drive letters to your source and target paths
subst K: "\\sharepoint\dept\gis\Abandoned_Wire"
subst L: "\\corp.dom\fs4\g1\OUTPUT\GRIDPROD\PDF\Maps\Abandon Wire Maps"
:: replicate the folder hierarchy
xcopy K: L: /t
:: recursively copy and touch all files
for /r K: %%F in (*) do (
xcopy "%%F" "L:%%~pnxF" /r /y
copy /b "L:%%~pnxF"+,, "L:%%~pF"
)
:: release the temporary drive mappings
subst /d K:
subst /d L: