[英]batch script to move files from one server to another older than 45 days
can someone help to write windows batch script to move files older than 45 days from one system to another whcih is added in network and domain.有人可以帮助编写 Windows 批处理脚本以将超过 45 天的文件从一个系统移动到另一个系统,该系统已添加到网络和域中。
Example : Move files older than 45 days from folders A, B, C of System1 to A, B, C of System 2.示例:将超过 45 天的文件从 System1 的文件夹 A、B、C 移动到 System 2 的 A、B、C。
I have tried running below code but it is working fine if my source and destination is same server but it is not working when source and destination is diff server.Server2 Folder ie A,B are shared folders and Server1 have access to it我试过运行下面的代码,但是如果我的源和目标是同一台服务器,它工作正常,但是当源和目标是不同的服务器时它不起作用。Server2 文件夹,即 A,B 是共享文件夹,Server1 可以访问它
@echo off & setlocal enableextensions
net use m: "\\System2\d$\A\"
Forfiles -p \\System1\d$\A -s -m *.* -d -45 -c "cmd /c move /y @FILE m: & echo %Date% Source File: @PATH to \\System2\d$\A\">>D:\Test\logfile.txt
net use /delete m:
net use n: "\\System2\d$\B\"
Forfiles -p \\System1\d$\B -s -m *.* -d -45 -c "cmd /c move /y @FILE n: & echo %Date% Source File: @PATH to \\System2\d$\B\">>D:\Test\logfile.txt
net use /delete m:
GOTO :eof
Take a look at robocopy.exe
.看看
robocopy.exe
。 It is part of standard installations since Vista/Server 2008. It has command line parameters that can be used to select files of certain ages.它是自 Vista/Server 2008 以来标准安装的一部分。它具有命令行参数,可用于选择特定年龄的文件。 Type
robocopy /?
robocopy /?
for details.详情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.