debbiez
asked on
I need a script to copy a source folder&subfolders to a target and append date to a files that change from initial copy.
I need a VB script that will take a folder named c:\home and all it's subfolders and copy that to d:\home and create the subfolders.
However, the next time and any time thereafter the VB script is run, it only needs to copy files that are new or have changed (looks at the archive bit) and if the file has changed it is not to overwrite the target but it should append the current date to the file name in the target folder. The customer wants a to retain copies in the target folders of each time the file has changed based on date. Can this be done and will someone help me :) I unfortunately can visually understand VB scripting but I underfortunately cannot program.
However, the next time and any time thereafter the VB script is run, it only needs to copy files that are new or have changed (looks at the archive bit) and if the file has changed it is not to overwrite the target but it should append the current date to the file name in the target folder. The customer wants a to retain copies in the target folders of each time the file has changed based on date. Can this be done and will someone help me :) I unfortunately can visually understand VB scripting but I underfortunately cannot program.
ASKER
XCOPY isn't going to append the date to changed files before it copies them over.
ASKER
Maybe a Visual Would Help:
C:\Home> test.txt (initial files)
D:\Home> test.txt (initial copy)
Then a change is made to test.txt
C:\Home> test.txt (now would have the archive bit turned on)
Then a script is run at night to copy the changed filed over to target which has BOTH the original version and now the changed:
D:\Home> test.txt ; test042206.txt
C:\Home> test.txt (initial files)
D:\Home> test.txt (initial copy)
Then a change is made to test.txt
C:\Home> test.txt (now would have the archive bit turned on)
Then a script is run at night to copy the changed filed over to target which has BOTH the original version and now the changed:
D:\Home> test.txt ; test042206.txt
How about locating the backups in a date-named subdirectory?
Example:
MD D:\HOME\Bkup060422
XCOPY C:\Home\*.* D:\Home\Bkup060422\ /e /s /a
=====================
* This way, the filenames don't change.
* You wouldn't have to use the /e flag if you didn't want empty directories.
* Keeping the file in a target folder doesn't seem like a good idea. If you don't like the above idea, consider the following:
+ Use Bkup060422_test.txt naming sceme
+ create Bkup060422 subdirectories in the places where you need to make the backups, as opposed to using it as the top-most (target) directory name.
=====================
You can also use a utility like WinZip to make the copy of just the changed files and reset their archived flags.
http://www.winzip.com/prodpagecl.htm
Example:
MD D:\HOME\Bkup060422
XCOPY C:\Home\*.* D:\Home\Bkup060422\ /e /s /a
=====================
* This way, the filenames don't change.
* You wouldn't have to use the /e flag if you didn't want empty directories.
* Keeping the file in a target folder doesn't seem like a good idea. If you don't like the above idea, consider the following:
+ Use Bkup060422_test.txt naming sceme
+ create Bkup060422 subdirectories in the places where you need to make the backups, as opposed to using it as the top-most (target) directory name.
=====================
You can also use a utility like WinZip to make the copy of just the changed files and reset their archived flags.
http://www.winzip.com/prodpagecl.htm
ASKER
Can't do it that way, NTFS security needs to be different on the target folders and I'd have to set the security individually each time. Not gonna happen. Customer wants it the way I described originally.
ASKER
Backup Exec which will run after the script, will reset the archive bit.
the simplest solution will use FileSystemObjects and recursive procedure calls. It can be done as you'd like. I'll see what I can whip up.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a bunch and I'll try this out! Hope it works. BTW, I already have the initial copy created with subfolders and everything on the target drive.
XCOPY src tgt /e /s /a