I realize that JavaScript is not usually used to copy folders or files, but I'm using a wsf file written in JavaScript for use only on my local system.
I'll give a simplified explanation of the problem I have: I have a folder C:/Program Files/Folder
, which has three files in it, File1, File2, and File3. I want to copy only File1 and File2, because File3 is unnecessary for me to copy, and is in use by another process which cannot be killed. (In reality I have a folder with hundreds of files, and I want to copy all of them except for one or two.) Aside from initializing each file and doing fso.fileCopy()
on each individual file, is there some way to copy the entire folder, excluding File3? Some kind of exclusion list maybe?
What I have:
var fso = new ActiveXObject("Scripting.FileSystemObject");
var originalFolder = fso.GetFolder("C:\\Program Files\\Folder");
originalFolder.Copy("D:\\Program Files\\Folder");
This would crash, since File3 is in use by a process. I don't want to have to do
var file1 = fso.getFile("C:\\Program Files\\Folder\\File1");
file1.Copy("D:\\Program Files\\Folder\\File1");
var file2 = fso.getFile("C:\\Program Files\\Folder\\File2");
file2.Copy("D:\\Program Files\\Folder\\File2");
for hundreds of files.
I am very new to scripting, so I'm not even sure if it's possible to do something like this in JavaScript.