option explicit ' **** UCCX WAV Archiving Tool ************************************************************************************** ' ************* V1.0 ************************************************************************************************ ' ** by Aaron Harrison, Logicalis UK ******************************************************************************** ' ******************************************************************************************************************* ' ** Usage: ********************************************************************************************************* ' ** ' ** Use at your own risk! ' ** ' ** Run as a scheduled task on the CRS Server. This script uses crsraw2wav.exe to perform the conversion from RAW ' ** to WAV, and this is found and runs only on the CRS box. ' ** ' ** crsraw2wav exports the WAV files, and this script collects them and moves them to a network drive. ' ** ' ** All script actions are logged to a file in c:\program files\cisco\desktop_wav and tidied up based on age. ' ** ' ** Known Caveats: ************************************************************************************************* ' ** ' ** If the script is set to delete the original WAV recording, it does NOT remove them from the Supervisor's ' ** recorded calls window. They will simply not play back... I run this script nightly and archive all calls, ' ** so Supervisors are instructed to use CSD to play back today's calls, and anything older will be on the archive. ' ** ' ******************************************************************************************************************* ' ** ' ** Mandatory Parameters: ' ** ' ** sOutputFolder - the final destination for the files on the network once the drive is mapped ' ** sNetworkSharePath - the UNC path to which the script should map a drive ' ** sNetworkShareUsername - username to map the network drive with ' ** sNetworkSharePassword - password to map the network drive with ' ** ' ** Optional Parameters: ' ** ' ** iKeepLogFilesForDays - the number of days to retain log files (log files are kept in the 'c:\program files\cisco\desktop_wav' folder which detail each action taken by the script ' ** iArchiveRecordingsOlderThan - files older than this number of days will be archived ' ** bDeleteSourceFilesAfterConversion - you may leave recordings on the CRS server or have the script delete the raw files to save space ' ** bStructureFilesByDate - creates subfolders on the output directory based on the date portion of the recording file names and stores recordings in these subfolders. ' ** ' ** *************************************************************************************************************** ' **** Edit these parameters: ******* dim sOutputFolder : sOutputFolder = "x:\CallRecordings\" dim iKeepLogFilesForDays: iKeepLogFilesForDays = 30 dim iArchiveRecordingsOlderThan : iArchiveRecordingsOlderThan = 0 dim bDeleteSourceFilesAfterConversion :bDeleteSourceFilesAfterConversion = true dim bStructureFilesByDate : bStructureFilesByDate = true dim sNetworkSharePath : sNetworkSharePath = "\\server\share" dim sNetworkShareUsername : sNetworkShareUsername= "username" dim sNetworkSharePassword : sNetworkSharePassword= "password" ' **** Do not edit below this line ***** dim sNetworkShareLetter : sNetworkShareLetter = left(sOutputFolder,2) dim sInputFolder : sInputFolder = "c:\program files\cisco\desktop_audio\" dim sLogFileBase : sLogFileBase = "c:\program files\cisco\desktop_wav\" dim sLogFileName : sLogFileName = "Conversion-" & FormatDateTime(Date(), 2) & ".txt" sLogFileName = replace(slogfilename,"/","") dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject") dim oLogFile dim sShellCommand, sOutputFile, sFinalWav dim iReturn dim oOutFile ' Init log file if not oFSO.folderExists(sLogFileBase) then oFSO.createFolder (sLogFileBase) end if if not oFSO.fileExists(sLogFileBase & sLogFileName) then set oLogFile = oFSO.createtextfile (sLogFileBase & sLogFileName , true) else set oLogFile = oFSO.openTextFile (sLogFileBase & sLogFileName, 8) end if oLogFile.writeline oLogFile.writeline (Now & " | Script started...") ' tidy up old log files oLogFile.writeline (Now & " | Checking for old log files...") dim objFolder : Set objFolder = oFSO.GetFolder(sLogFileBase) dim colFiles : Set colFiles = objFolder.Files dim objFile For Each objFile In colFiles if left(objFile.name, 11) = "Conversion-" then if right(objFile.name, 3) = "txt" then if DateDiff("d", objFile.DateCreated, Now) > (iKeepLogFilesForDays + 1) then oLogFile.writeline (Now & " | Deleting log " & objFile.name) objFile.delete end if end if end if next oLogFile.writeline (Now & " | Done checking for old log files...") dim oNetwork : set oNetwork = wscript.createObject("wscript.Network") dim oShell : set oShell = wscript.createObject("wscript.shell") Set objFolder = oFSO.GetFolder(sInputFolder) Set colFiles = objFolder.Files on error resume next iReturn = oNetwork.removenetworkdrive(sNetworkShareLetter,true,false) iReturn = oNetwork.mapnetworkdrive(sNetworkShareLetter, sNetworkSharePath, false, sNetworkShareUsername, sNetworkSharePassword) if err.number > 0 then oLogFile.write (Now & " | Possible error mapping " & sNetworkShareLetter & " to " & sNetworkSharePath) else oLogFile.write (Now & " | Mapped " & sNetworkShareLetter & " to " & sNetworkSharePath) end if on error goto 0 err.clear For Each objFile In colFiles if DateDiff("d", objFile.DateCreated, Now) > (iArchiveRecordingsOlderThan) then if right(objFile.name,7) = ".To.Raw" then oLogFile.writeline oLogFile.write(Now & " | Converting(" & objFile.name & ") |") sShellCommand = "cmd.exe /C " & chr(34) & "c:\program files\cisco\desktop\bin\crsraw2wav.exe" & chr(34) & " " & + objFile.name iReturn = oShell.Run(sShellCommand,0,true) sOutputFile = "c:\program files\cisco\desktop_wav\" & (lcase(left(objFile.name, (len(objfile.name)-7)))) & ".wav" if oFSO.fileexists(sOutputFile) then oLogFile.write (" Verified Wav File OK |") set oOutFile = oFSO.getfile(sOutputFile) err.clear if bStructureFilesByDate then if not oFSO.folderexists (sOutputFolder & left(objFile.name,8)) then 'debug wscript.echo ("Attempting to create " & (sOutputFolder & left(objFile.name,8))) oFSO.createFolder (sOutputFolder & left(objFile.name,8)) end if sFinalWav = sOutputFolder & left(objFile.name,8) & "\" & (lcase(left(objFile.name, (len(objfile.name)-7)))) & ".wav" else sFinalWav = sOutputFolder & (lcase(left(objFile.name, (len(objfile.name)-7)))) & ".wav" end if if oFSO.fileexists(sFinalWav) then 'debug wscript.echo "Pre-copy check - file exists in destination |" oLogFile.write (" * Pre-copy check - File exists in destination * |") oOutFile.delete else if bStructureFilesByDate then 'debug wscript.echo ("Moving to " & (sOutputFolder & left(objFile.name,8) & "\")) oOutFile.move (sOutputFolder & left(objFile.name,8) & "\") else 'debug wscript.echo("Moving to " & (sOutputFolder)) oOutFile.move (sOutputFolder) end if ' Post Copy Checks if oFSO.fileexists(sFinalWav) then 'debug wscript.echo (" Post Copy Check - File Copied OK : " & sFinalWav) oLogFile.write (" Post Copy Check - File Copied OK |") else 'debug wscript.echo (" * Post CopyCheck - File Not Found in Dest * |") oLogFile.write (" * Post CopyCheck - File Not Found in Dest * |") oOutFile.delete end if end if if bDeleteSourceFilesAfterConversion then if oFSO.fileexists(sFinalWav) then dim sRawBaseFileName sRawBaseFileName = left(objFile.name,(len(objFile.name) - 7)) oLogFile.write (" Deleting RAW Files") oFSO.deleteFile(sInputFolder & sRawBaseFileName & ".From.Raw") oFSO.deleteFile(sInputFolder & sRawBaseFileName & ".To.Raw") else oLogFile.write (" * Could not verify final WAV file...source not deleted * ") end if end if else if iReturn = 0 then oLogFile.write (" * WAV File Missing, but no Conversion error * |") elseif iReturn = 1 then oLogFile.write (" * WAV File Missing, and Error in Conversion * |") end if end if end if end if Next