Guest_imported
New member
- Jan 1, 1970
- 0
The code below will successfully copy all contents of a folder to another one, and also all files. Now I'm trying to figure out how to use the archive Attribute property so that during this copying process it checks each file's archive attribute and only copies files that are new or have been modified.
Anyone have code to do this or have suggestions on how to make it test each file just prior to copying? I have an example of a "ToggleArchiveBit" function below that ought to be able to be modified for this purpose.
Probably using an IF statement...but I'm not sure how to separate each file being copied out from the CopyFolder and CopyFile commands. Do I need to use some kind of looping function, like this?
For i = filespec
copy the files etc...
Next i
Any suggestions would be most welcome. I'm interested in making scripts to automate copying/moving files/folders and backing up data. Another question: don't suppose anyone has a script that could also do this directly to a CD-R/W, perhaps by launching and controling a burning software such as Easy Creator or Nero? Just another aside question...
Here's the example of my code, which is still very useful stuff! I downloaded the latest version of VBScript 5.6, Which if you're interested is at:
' VBScript.
' NOTE THIS TEXT FILE MUST END IN THE EXTENSION .VBS AND HAVE THE VBSCRIPT.EXE,
' WSCRIPT.EXE ALREADY INSTALLED (LATEST VERSION AS OF 8/7/02 WAS 5.6)
'
' TEST OF COPYING ALL FOLDERS/FILES FROM THE DRIVE ITSELF TO ANOTHER FOLDER
' NOTE THAT THE DESTINATION FOLDER MUST ALREADY EXIST FOR THIS TO WORK AND
' IT CANNOT HAVE WILDCARDS
'
' THIS WORKS! IT FIRST COPIES ALL THE FOLDERS IN DRIVE A: AND THEIR CONTENTS, THEN
' IT COPIES ALL FILES FROM THE ROOT DIR OF A:. COMBINING BOTH FUNCTIONS WILL
' ALLOW COPYING OF ALL FILES AND FOLDERS
'
' NOTE THAT THE DEFAULT IS TO OVERWRITE EXISTING FILES
' THE FILE SYSTEM OBJECT MUST FIRST BE DEFINED AND SET AS FOLLOWS:
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject"
' THIS WORKS TO COPY ALL FOLDERS AND THEIR CONTENTS FROM DRIVE A: INTO
' THE ATESTAGAIN FOLDER. NOTE WILDCARDS ARE NOT ALLOWED FOR DESTINATION
FSO.CopyFolder "A:\*.*", "F:\Data\atestagain"
' NOTE THAT IF YOU SPECIFIED A SPECIFIC FOLDER, IT WOULD COPY ALL FOLDERS
' WITHIN THAT PARTICULAR FOLDER AND THEIR CONTENTS. SYNTAX LOOKS LIKE THIS:
' FSO.CopyFolder "c:\x", "c:\y" WHERE X IS SOURCE, Y IS DESTINATION
' THIS WORKS TO COPY ALL FILES (NOT FOLDERS) IN THE ROOT DIR OF A: INTO
' THE ATESTAGAIN FOLDER
FSO.CopyFile "A:\*.*", "F:\Data\atestagain"
'NOTE: MIGHT ALSO BE ABLE TO USE THE ATTRIBUTE FUNCTION TO COPY ONLY FILES
' THAT HAVE BEEN MODIFIED. HERE IS AN EXAMPLE THAT MIGHT BE USEFUL:
' Function ToggleArchiveBit(filespec)
' Dim fso, f
' Set fso = CreateObject("Scripting.FileSystemObject"
' Set f = fso.GetFile(filespec)
' If f.attributes and 32 Then
' f.attributes = f.attributes - 32
' ToggleArchiveBit = "Archive bit is cleared."
' Else
' f.attributes = f.attributes + 32
' ToggleArchiveBit = "Archive bit is set."
' End If
' End Function
Anyone have code to do this or have suggestions on how to make it test each file just prior to copying? I have an example of a "ToggleArchiveBit" function below that ought to be able to be modified for this purpose.
Probably using an IF statement...but I'm not sure how to separate each file being copied out from the CopyFolder and CopyFile commands. Do I need to use some kind of looping function, like this?
For i = filespec
copy the files etc...
Next i
Any suggestions would be most welcome. I'm interested in making scripts to automate copying/moving files/folders and backing up data. Another question: don't suppose anyone has a script that could also do this directly to a CD-R/W, perhaps by launching and controling a burning software such as Easy Creator or Nero? Just another aside question...
Here's the example of my code, which is still very useful stuff! I downloaded the latest version of VBScript 5.6, Which if you're interested is at:
' VBScript.
' NOTE THIS TEXT FILE MUST END IN THE EXTENSION .VBS AND HAVE THE VBSCRIPT.EXE,
' WSCRIPT.EXE ALREADY INSTALLED (LATEST VERSION AS OF 8/7/02 WAS 5.6)
'
' TEST OF COPYING ALL FOLDERS/FILES FROM THE DRIVE ITSELF TO ANOTHER FOLDER
' NOTE THAT THE DESTINATION FOLDER MUST ALREADY EXIST FOR THIS TO WORK AND
' IT CANNOT HAVE WILDCARDS
'
' THIS WORKS! IT FIRST COPIES ALL THE FOLDERS IN DRIVE A: AND THEIR CONTENTS, THEN
' IT COPIES ALL FILES FROM THE ROOT DIR OF A:. COMBINING BOTH FUNCTIONS WILL
' ALLOW COPYING OF ALL FILES AND FOLDERS
'
' NOTE THAT THE DEFAULT IS TO OVERWRITE EXISTING FILES
' THE FILE SYSTEM OBJECT MUST FIRST BE DEFINED AND SET AS FOLLOWS:
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject"
' THIS WORKS TO COPY ALL FOLDERS AND THEIR CONTENTS FROM DRIVE A: INTO
' THE ATESTAGAIN FOLDER. NOTE WILDCARDS ARE NOT ALLOWED FOR DESTINATION
FSO.CopyFolder "A:\*.*", "F:\Data\atestagain"
' NOTE THAT IF YOU SPECIFIED A SPECIFIC FOLDER, IT WOULD COPY ALL FOLDERS
' WITHIN THAT PARTICULAR FOLDER AND THEIR CONTENTS. SYNTAX LOOKS LIKE THIS:
' FSO.CopyFolder "c:\x", "c:\y" WHERE X IS SOURCE, Y IS DESTINATION
' THIS WORKS TO COPY ALL FILES (NOT FOLDERS) IN THE ROOT DIR OF A: INTO
' THE ATESTAGAIN FOLDER
FSO.CopyFile "A:\*.*", "F:\Data\atestagain"
'NOTE: MIGHT ALSO BE ABLE TO USE THE ATTRIBUTE FUNCTION TO COPY ONLY FILES
' THAT HAVE BEEN MODIFIED. HERE IS AN EXAMPLE THAT MIGHT BE USEFUL:
' Function ToggleArchiveBit(filespec)
' Dim fso, f
' Set fso = CreateObject("Scripting.FileSystemObject"
' Set f = fso.GetFile(filespec)
' If f.attributes and 32 Then
' f.attributes = f.attributes - 32
' ToggleArchiveBit = "Archive bit is cleared."
' Else
' f.attributes = f.attributes + 32
' ToggleArchiveBit = "Archive bit is set."
' End If
' End Function