November 9, 2000 - Moving Files | WebReference

November 9, 2000 - Moving Files

Yehuda Shiran November 9, 2000
Moving Files
Tips: October 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

To move a file from one location to another, use the move() method of the File object. Its syntax is the following:


where destination is where you want the file to be moved to.

Here is a piece of script that will move a file from drive c to drive d:

myActiveXObject = new ActiveXObject("Scripting.FileSystemObject");
file = myActiveXObject.GetFile("c:\\test.txt");
file.copy("d:\\", true);
// -->

Notice that you don't have to specify a new name for the moved file, but just the new folder where to move it to. The file will keep its original name.