View Full Version : Javascript FTO program help

03-19-2012, 06:58 AM
Hello people CF,

I need some help with this Javascipt program that im trying to make. Ill provide you with the algorithm i have made and the javascript code. I only know basic javascripting and i had a lot of help with this. I need help getting the javascript code for comparing last date modified, renaming the copied file with last date modified, also i can get it to copy 1 file, but i need it to loop through all the files in the given folder.


// get source and destination folder path
// check if folder exists
// if source folder exists, continue with the process, otherwise display an error message
// if destination folder exists, proceed with transferring the files
// get the file collections in the source folder
// loop through each file to check if the file has been modified
// if the file exists, check file attributes to the source file; 32 means file has changed
// if file has changed,
// compare the last date modified of the source and destination file
// if the source last date modified is greater than the destination last date modified then
// rename the destination file by appending the last date modified
// to its file name and then transfer the lastest file from the source folder
// otherwise, no need to copy the file and move to the next file
// otherwise, do nothing and move on to the next file
// otherwise, create a folder first before proceeding with transferring the files

I had a lot of help with this

<TITLE>FileSystem Object Demo</TITLE>
<SCRIPT> Language = "JavaScript">
<!--hide from old browsers
function checkExistingFolder(folder)
var FS = new ActiveXObject("Scripting.FileSystemObject");

return FS.FolderExists(folder);
function createFolder(folder)
var FS = new ActiveXObject("Scripting.FileSystemObject");
document.write ("<BR>New folder created.");
function copyFile(source, dest)
var FS = new ActiveXObject("Scripting.FileSystemObject");
FS.copyFile(source + "\\Test.txt", dest + "\\Test.txt");
document.write ("<BR>File Copied.");
function runProgram ()
var from = document.getElementById('from').value;
var to = document.getElementById('to').value;
var isExist = checkExistingFolder(to);

document.write("Folder Exists, checking last date modified........");
document.write("Folder doesn't exist.");
copyFile(from, to);
// -->
<BODY background="1330843076080.jpg">
<H1>FileSystem Object Demo</H1>
FROM: <input type="text" id="from" value=""/>
TO: <input type="text" id="to" value="d:\\test"/>
<input type="button" onClick="runProgram()" value="Transfer Files"/>
<SCRIPT LANGUAGE = "JavaScript">
<!--hide from old browsers

// -->