Javascript FileSystemObject (FSO) MoveFile method provides the functionality similar to cut and paste function of windows. FSO MoveFile method moves the specified source file from one place to other specified location at client’s PC. MoveFile method supports wild card characters that allow you to move multiple files based on the filter or search string generated by the wild card characters in the source file path. Destination path of FSO MoveFile method does not support wild card characters. 

Syntax for Javascript FSO MoveFile Method

fso.MoveFile(source, destination);

FSO MoveFile method accepts two parameters as follows:

1. source: path of the source file or files to be moved to other location. Wild card characters allow you to move multiple files to other location.

2. destination: path of the destination folder where source file or files to be moved. This parameter does not support wild card characters. 

Note: destination path must end with directory separation symbol i.e. “\” 

Example of Javascript FSO MoveFile Method

<script type="text/javascript">
    // initialize ActiveXObject and create an object of Scripting.FileSystemObject.
    var fso = new ActiveXObject("Scripting.FileSystemObject");

    fso.MoveFile("C:\\Temp\\file.txt", "C:\\Temp\\myFolder\\");

    fso = null;
</script>

Continue to next turorial: Javascript FSO MoveFolder Method to learn how to move the directory from one location to another.

Recent JavaScript Tutorials

Javascript FSO ShortPath property

Javascript FileSystemObject (FSO) provides a ShortPath property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Path Property

Javascript FileSystemObject (FSO) provides the Path property that can be accessed through the file object or folder object returned by the GetFile or GelFolder method

Javascript FSO Type property

Javascript FileSystemObject (FSO) provides a Type property that can be accessed through file object or folder object returned by the GetFile or GetFolder method

Javascript FSO ShortName property

Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Name Property

Javascript FileSystemObject (FSO) provides a Name property that can be accessed using file object or folder object.