Article ID: 10099
SAMPLE: Renaming the 'Specified Output File' using Data Processing Scripts
SAMPLE
Applies To: ITScriptNet V1/V2

This sample shows how to rename the output file (defined in Configure recieve screen) after the collected data has been processed. Code to accomplish this task must be written in VBScript because it executes in the Data Processing Scripts which only interpret VBScript Language.

This functionality keeps each download in a seperate output file so the contents of the previous download do not get appended to or overwritten be y the current data.

DETAILS

Place the following code in the 'After Processing Data' script of the Data Processing scripts (Program->Configure Receive->Edit Scripts...).
'CREATE FILE SYSTEM OBJECT
Set oFSO = CreateObject("Scripting.FileSystemObject")

'GET CURRENT FOLDER
Set oFolder = oFSO.GetFolder(".")

'GET THE PATH OF THE CURRENT FOLDER
sDir = oFSO.GetAbsolutePathName(oFolder)

'GET YEAR, MONTH, DAY, HOUR, MINUTE, SECOND
sYR = Year(Now)
sMTH = Right("00" & Month(Now),2)
sDAY = Right("00" & Day(Now),2)
sHR = Right("00" & Hour(Now),2)
sMIN = Right("00" & Minute(Now),2)
sSEC = Right("00" & Second(Now),2)

'CONCATENATE DATE (YYYYMMDD)
sDate= sYR & sMTH & sDAY

'CONCATENATE TIME (HHNNSS)
sTime = sHR & sMIN & sSEC

'CREATE COPY OF FILE - APPENDING THE DATE/TIME (dataYYYYMMDDHHNNSS.txt)
oFSO.CopyFile sDir & "\data.txt", sDir & "\data" & sDate & sTime& ".txt",true

'DELETE ORIGINAL FILE
oFSO.DeleteFile sDir & "\data.txt",true

'CLEAN UP OBJECTS
Set oFOLDER = Nothing
Set oFSO = Nothing

This Script uses VBScript's File System Object to accomplish the following tasks:
  • Gets the Current Folder
  • Gets the FULL Path of the Current Folder
  • Creates a copy of the specified file (appending the current Date/Time tot he file name)
  • Deletes the original specified output file
* The renamed output file should be uniquely named or it can possibly overwrite an existing file. It is recommended to append the current Date and Time to the output file name to ensure its uniqueness.

This article last updated: 1/1/2009 12:00:00 AM
Please help us improve the Knowledge Base by rating this article.
    © 1997-2026 Z-Space Technologies - a BCA Innovations Company - All rights reserved