copying files by date 
Author Message
 copying files by date

I would like to know how I can copy files, that were modified today
from one folder to another , (the idea is to make every day a backup
of all the modified files of the day)
thanks for help

Daniel




Sat, 08 Mar 2003 03:00:00 GMT  
 copying files by date
In DOS I use xcopy32 /m (copies all files with archive flag set, clears
archive bit)

This has the effect of only copying files that were modified.
(Every time you edit or save a file it sets the archive bit.  The above line
clears all archive bits on files that were backed up so next time only
modified files will be copied.)

But if you insist on going by date, the helpfile says to make xcopy32 copy
all files after a certain date:

xcopy32 c:\data d:\backups /d:010100 /e /v
The /d:010100 tells xcopy32 to copy all files after a certain date (January
1, 2000)
The /e tells xcopy32 to copy all subdirectorys even if empty.  The /v
verifies each file to make sure it's correct.  Both the /e and /v are
optional.  I just threw them in because I thought they might be handy for
backing up entire directory trees accurately.

As a shell object in .vbs I get

Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "xcopy32 c:\data d:\backups /d:010100 /e /v"

If there's a more elegant solution (that doesn't use DOS), I'd like to know.



Sat, 08 Mar 2003 03:00:00 GMT  
 copying files by date

As already suggested, it's sometimes easier to automate an existing DOS command than to implement a
VBScript solution.

Here's a very simple example of how you would use FSO to copy files in a given folder based on date.
A "real" implementation would include error handling...

set fso = createobject("scripting.filesystemobject")
today = date()
frompath = "c:\my source folder\"
destpath = "c:\my backup folder\"
set folder = fso.getfolder(frompath)
s = ""
for each file in folder.files
  if datevalue(file.DateLastModified) = today then
    s = s & file.name & vbcrlf
    file.copy destpath,true
  end if
next

msgbox "Copied:" & vbcrlf & s

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:

> I would like to know how I can copy files, that were modified today
> from one folder to another , (the idea is to make every day a backup
> of all the modified files of the day)
> thanks for help

> Daniel





Sat, 08 Mar 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Copying File with Date

2. copying files by date

3. Find a copy a file with File.Copy method

4. Copy multiple files and checking if all files are copied

5. --- copying a PostSctipt file with the DOS COPY command

6. Copy a file in a folder and past the copy in another folder

7. Copy to file with new name...Copy() and CopyFile() inadequate

8. Copy script with date in the name - blind mind

9. how to use Volume Shadow Copy to copy an in use file

10. Copy a bunch of files but can't cancel in the middle of copy

11. copy folder and copy files

12. File Creat Date and Modified Date...

 

 
Powered by phpBB® Forum Software