aceklub97
asked on
VBScript - using fso.CopyFile to create a subfolder in a directory and copying several files into that subdirectory
Greeting,
I was wondering if someone could help me. I am trying to 1. use the copy function to copy several different individual files from different directories 2. Create a sub directory in the backup directory, 3. copy all the fils into that subfolder.
The problem that I am running into is as follows:
1. When I use
fso.CopyFile "C:\Programs\Extra\*.ini" , strBackupFolder
It will copy all fifty or so files loose into the directory, and that is a problem, because I don't want to get them mixed up with other .ini files from.
2. When I use
fso.CopyFolder strSessionsPath , folder.path & "\LogFiles", True
It will create the subdirectory that I want, "LogFiles" in the strBackupFolder, but then I have to copy the entire folder over. This won't work either, because the source folder is over 2GB.
Is there any method that I can use where I am using the copyfile method, but still able to create the subdirectory and copy the files to it?
I was wondering if someone could help me. I am trying to 1. use the copy function to copy several different individual files from different directories 2. Create a sub directory in the backup directory, 3. copy all the fils into that subfolder.
The problem that I am running into is as follows:
1. When I use
fso.CopyFile "C:\Programs\Extra\*.ini" , strBackupFolder
It will copy all fifty or so files loose into the directory, and that is a problem, because I don't want to get them mixed up with other .ini files from.
2. When I use
fso.CopyFolder strSessionsPath , folder.path & "\LogFiles", True
It will create the subdirectory that I want, "LogFiles" in the strBackupFolder, but then I have to copy the entire folder over. This won't work either, because the source folder is over 2GB.
Is there any method that I can use where I am using the copyfile method, but still able to create the subdirectory and copy the files to it?
Hi,
Sorry, I don't exactly catch 100% of what you are trying to achieve. But I am guessing xcopy is what you want.
Check out the code to execute xcopy from vbscript.
Sorry, I don't exactly catch 100% of what you are trying to achieve. But I am guessing xcopy is what you want.
Check out the code to execute xcopy from vbscript.
DIM objShell
set objShell = wscript.createObject("wscript.shell")
'The dos window will not close. Good for debugging.
iReturn = objShell.Run("CMD /K xcopy c:\temp\test c:\temp\backup /e /y >C:\temp\test.log")
'The dos window will close. Good for production run.
'iReturn = objShell.Run("CMD /C xcopy c:\temp\test c:\temp\backup /e /y >C:\temp\test.log")
ASKER
Ok I am making progress, but I am not used to using the DOS, so bear with me. This is what I have. I already have a backup folder set up as strBackupFolder, and I am trying to create a subfolder named XactimateDB with the contacts of the source folder copied into this subfolder. I think that I still have some syntax wrong.
Dim Shell, ireturn, xactimateDBPathFolder
xactimateDBPathFolder = "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\
Set shell = wscript.createobject("wscr
'iReturn = Shell.Run("CMD /C xcopy xactimateDBPathFolder strBackupFolder & "\XactimateDB" /e /y >"C:\program files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\
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 for the help. That worked and I can use work with that.
Or if you want to run it more than once a day, you could use date & time.
Try making a script with these 3 lines:
wscript.echo date
wscript.echo time
wscript.eco date & " " & time
You can of course, if you want no space between the date and the time
juse make the third line, like this
wscript.echo date & time