Results 1 to 1 of 1
Oct 19, 2010, 05:59 #1
- Join Date
- Jan 2006
- 0 Post(s)
- 0 Thread(s)
VBScript CopyFolder Method Problem
First of all sorry if this is in the wrong section, but I couldn't see a better place for a VBScript topic!
Too long; didn't read
CopyFolder method in my VB script doesn't copy all of the files contained in a folder. Most files copy, but two don't. File permissions are the same, and the VB script copies the two troublesome files across OK if I manually add a line of code to copy those two specific files. Any ideas why?
I'm having a bit of trouble with a small VB script that someone else wrote, although I'm not sure that it's the script that's the cause of the problem.
Basically, I've got a small VB script that copies a folder (and it's sub-folders and files) to another directory. The files it's copying are mostly .gz zip files, created by a program that our company uses for something or other.
Anyway, up until recently the script has worked fine, but over the last week or so we've had two instances whereby it misses a file when copying. There are around 15 other files in the same directory, and they all get copied just fine, but for some reason these two files simply don't copy over.
I'm using the FileSystemObject object, and my (slightly edited) code is as follows:
Dim objFSO Set objFSO = CreateObject("Scripting.FilesystemObject") objFSO.CopyFolder <source>, <destination>, TRUE
There's no error given, and everything else is copying across OK.
Does anyone know what might be happening? As far as I can tell, the only difference between the files not being copied and all the other files is that they were created recently by this program, and when the script runs for the first time after new files are created, it's only the new files that aren't copied.
Is there any reason why the "FileSystemObject.CopyFolder" method will copy some files but not others? I've checked the file permissions and they seem to be the same as all of the other files.
No new files have been created by the program for a few months as far as I can see, so the script was just happily copying the same old files each day. My guess is that at some point in the last few months, a new version of the program was installed and it somehow creates files in such a way that the script can't copy them, but other than file permissions I don't know what else to check.
Interestingly (depending on who you ask) I can add a line of code to manually copy the files to the <destination> folder (using the "FileSystemObject.CopyFile" method) and it works a treat, but I can't keep adding a new line of code for every file the program creates so that those files get copied.
A little help would be awesome, thanks!