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.