VB 脚本 + 仅复制具有不同修改日期的文件 [英] VB scripts + copy only files that has different modify date

查看:34
本文介绍了VB 脚本 + 仅复制具有不同修改日期的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下VB脚本(Shell对象)复制文件夹&文件从 \server\kits_location 到 D:\ ,

I Use the following VB script( Shell object ) to copy folders & files from \server\kits_location To D:\ ,

我们还会在复制文件夹时显示复制文件"进度对话框.

We also get Displays of the Copying Files progress dialog as the folder is being copied.

源路径 - \\server\kits_location

目标路径 - D:\

此 VB 脚本每周运行一次,以更新目标驱动器D:\"上的文件

This VB script run every week in order to update files on the target drive "D:\"

通常源文件 ( \server\kits_location ) 上的文件未修改,因此在这种情况下,源文件与目标文件之间没有区别

Usually files on source ( \server\kits_location ) not modified so in this case we not have difference between source files to target files

因为文件很大(1-10G),

Because files are very big ( 1-10G) ,

我只想复制修改日期不同的文件

I want to copy only files that have different modify date

因此只有与目标文件具有不同修改日期的源文件才会复制到目标驱动器 (D:\)

so only source files that has diff modify date from target files will copied to target drive ( D:\ )

请建议我需要在我的 VB 脚本中添加什么,以便仅将差异文件从源复制到目标

Please advice what I need to add in my VB script in order to copy only the diff files from source to target

我的 VB 脚本

     createobject("wscript.shell").popup "Start Copy FCO Kits from network server - \\server\kits_location\ to D:\ drive ", 2, "", 64 
     Set objShell = CreateObject("Shell.Application")
     Const FOF_CREATEPROGRESSDLG = &H0&
     strPictureTargetDIR = "D:\" 
     Set objFolder = objShell.NameSpace(strPictureTargetDIR) 
     ' Copy  Kits from network server to D:\ drive
     objFolder.CopyHere "\\server\kits_location\", FOF_CREATEPROGRESSDLG
     set objShell = Nothing

推荐答案

你可以像这样使用 XCOPY 从源目录复制到目标目录

You could use XCOPY like this to copy from a source to destination directory

请更改您的路径以适合

我使用过这些开关

  • /f 复制时显示完整的源和目标文件名.
  • /d 复制所有比现有目标文件更新的源文件
  • /s 复制文件夹和子文件夹,除了空文件夹.
  • /e 复制任何子文件夹,即使它是空的.
  • /y 覆盖现有文件而不提示您
  • /h 复制隐藏文件和系统文件.
  • /r 覆盖只读文件

Dim Path1
Dim Path2
Path1 = "C:\temp\*.*"
Path2 = "C:\test\"
Call XcopyFiles(Path1, Path2)

Sub XcopyFiles(strSource, strDestination)
    Dim wsh
    Set wsh = CreateObject("wscript.shell")
    wsh.Run "xcopy.exe """ & strSource & """ """ & strDestination & """ /f /d /s /e /y /h /r", 1, True
    Set wsh = Nothing
End Sub

这篇关于VB 脚本 + 仅复制具有不同修改日期的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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