Advertisement
jcunews

DateCopy.vbs

Feb 19th, 2019 (edited)
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Copies the last modification date of the specified source to the specified destination.
  2. 'Source and destination can be a file or a directory.
  3.  
  4. if wscript.arguments.count < 2 then
  5.   wscript.echo "Usage: datecopy {source} {destination}"
  6.   wscript.quit 1
  7. end if
  8.  
  9. set fs = createobject("scripting.filesystemobject")
  10. on error resume next
  11.  
  12. set src = fs.getfile(wscript.arguments(0))
  13. if err.number <> 0 then
  14.   set src = fs.getfolder(wscript.arguments(0))
  15.   if err.number <> 0 then
  16.     wscript.echo "Source file/directory is invalid or not found."
  17.     wscript.quit 2
  18.   end if
  19. end if
  20.  
  21. set dest = fs.getfile(wscript.arguments(1))
  22. if err.number <> 0 then
  23.   set dest = fs.getfolder(wscript.arguments(1))
  24.   if err.number <> 0 then
  25.     wscript.echo "Destination file/directory is invalid or not found."
  26.     wscript.quit 2
  27.   end if
  28. end if
  29.  
  30. on error goto 0
  31. set sa = createobject("shell.application")
  32. set fd = sa.namespace(dest.parentfolder.path)
  33. set fi = fd.parsename(dest.name)
  34. fi.modifydate = src.datelastmodified
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement