QUOTE
"d:\\Program Files\\Intellipool Network Monitor" settings.nxd d:\\INMSettingsBackup
The first parameter is the directory the file is in (Leave off the trailing \)
The second parameter is the name of the file that I want to copy
The third parameter is the destination folder I want to put my copies.
CODE
----------------------------------------------------------------------------------------------------------
-- Name: BackupFile.lua
-- Version: 1.0
-- Date: 2007-11-28
-- Description: Creates a backup copy of a file in the specified folder. Files are tagged with
-- the script execution time in YYYYMMDDhhmmss format.
-- Arguments:
-- 1) Path of file to backup
-- 2) Name of file to backup
-- 2) Destination Folder to copy to
----------------------------------------------------------------------------------------------------------
backuppath = GetArgument(0);
backupfile = GetArgument(1);
destination = GetArgument(2);
--get the current date
d = TLuaDateTime();
--build the path to the file to backup.
fn = backuppath .. "\\" .. backupfile;
--build the path to the destination file name.
fn2 = destination .. "\\" .. backupfile .. "." .. d:GetDate("%Y%m%d") .. "_" .. d:GetTime("%H%M%S");
--copy the file to the destination.
file = TLuaFile();
result = file:CopyFile(fn, fn2);
if (result == 0) then
error = GetLastError();
errdesc = FormatErrorString(error);
SetExitStatus(error .. " - " .. errdesc,false);
else
SetExitStatus("File copied to " .. fn2,true);
end
-- Name: BackupFile.lua
-- Version: 1.0
-- Date: 2007-11-28
-- Description: Creates a backup copy of a file in the specified folder. Files are tagged with
-- the script execution time in YYYYMMDDhhmmss format.
-- Arguments:
-- 1) Path of file to backup
-- 2) Name of file to backup
-- 2) Destination Folder to copy to
----------------------------------------------------------------------------------------------------------
backuppath = GetArgument(0);
backupfile = GetArgument(1);
destination = GetArgument(2);
--get the current date
d = TLuaDateTime();
--build the path to the file to backup.
fn = backuppath .. "\\" .. backupfile;
--build the path to the destination file name.
fn2 = destination .. "\\" .. backupfile .. "." .. d:GetDate("%Y%m%d") .. "_" .. d:GetTime("%H%M%S");
--copy the file to the destination.
file = TLuaFile();
result = file:CopyFile(fn, fn2);
if (result == 0) then
error = GetLastError();
errdesc = FormatErrorString(error);
SetExitStatus(error .. " - " .. errdesc,false);
else
SetExitStatus("File copied to " .. fn2,true);
end