批处理以比较来自不同文件夹中的两个文件的最后修改 [英] Batch to compare last-modify from two files in different folders

查看:120
本文介绍了批处理以比较来自不同文件夹中的两个文件的最后修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个批处理文件,该文件将比较位于两个不同文件夹中的两个不同文件的last-modify日期.如果本地文件早于服务器文件,我想覆盖本地文件.

I want a batch file that will compare the last-modify date of two different files located in two different folders. If the local file is older than the server file, I want to overwrite the local file.

我找到的所有内容都与dir命令进行了比较,该命令仅在两个文件都位于同一文件夹(例如dir /b /OD file1.txt file2.txt)中时才起作用.

All I've found yet it a comparing the files with the dir command, which only works when both files are in the same folder (eg. dir /b /OD file1.txt file2.txt).

这是我实际上得到的,只需添加比较:

This is what I got actually, just need to add the comparison:

set "source=\\server\myApp.otm"
set "target=%userprofile%\Application Data\myApp\"

copy /Y /B "%source%" "%target%"
start outlook.exe /altvba "%target%\myApp.otm"

如您所见,批处理文件在此处以参数中的 VBA * OTM *文件启动Outlook.我不想每次都不需要从服务器复制10MB文件,因此需要比较last-modify日期(我想也是filesize也可以).

As you can see, the batch file is here to start Outlook with the VBA *OTM* file in parameter. I don't want to copy the 10MB file from the server each time if it isn't needed, thus the need for a comparison of last-modify dates (filesize would be okay too I guess).

推荐答案

尝试xcopy /d \\server\myapp.otm %userprofile%\...仅当它比本地文件新时,才会复制服务器文件

try xcopy /d \\server\myapp.otm %userprofile%\... it will copy the server file only if it is newer than the local file

这篇关于批处理以比较来自不同文件夹中的两个文件的最后修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆