Jump to content

Will this work?


Recommended Posts

I've put some code together for copying / moving some server logs. I've added the FileCopy part, FileMove part worked before without problems. Now it appears it is not working - any advice would be helpful:

#include <Date.au3>
#include <File.au3>

$srcfolder = "C:\WINDOWS\system32\LogFiles\W3SVC1" ; Set the source folder
$FileList = _FileListToArray($srcfolder) ; List all files in the array
$arTime = StringSplit(_DateAdd("D", -1, _NowCalcDate()), "/") ; Split yesterdays date up by the / delimeter
Dim $newTime
For $a = 1 To UBound($arTime) - 1
    $newTime &= $arTime[$a] ; Everytime we find a piece of the date, concatenate it
Next

For $i = 1 To UBound($FileList) - 1 ; For each file in the array
    $FileTime = StringTrimRight(FileGetTime($srcfolder & "\" & $FileList[$i], 0, 1), 6) ; Get its creation date as a string and trim the time off
    If $FileTime <= $newTime Then ; If the file date matches the current date
        FileCopy($srcfolder & "\" & $FileList[$i], "\\msmq.domain.local\IISLogs\WEB01", 1) ; Copy the file to MSMQ
        FileMove($srcfolder & "\" & $FileList[$i], "\\fileshare.domain.local\TraceLogs\WEB-01-W3SVC", 1) ; Move the file
    EndIf
Next
Edited by skysel
Link to comment
Share on other sites

I've put some code together for copying / moving some server logs. I've added the FileCopy part, FileMove part worked before without problems. Now it appears it is not working - any advice would be helpful:

#include <Date.au3>
#include <File.au3>

$srcfolder = "C:\WINDOWS\system32\LogFiles\W3SVC1" ; Set the source folder
$FileList = _FileListToArray($srcfolder) ; List all files in the array
$arTime = StringSplit(_DateAdd("D", -1, _NowCalcDate()), "/") ; Split yesterdays date up by the / delimeter
Dim $newTime
For $a = 1 To UBound($arTime) - 1
    $newTime &= $arTime[$a] ; Everytime we find a piece of the date, concatenate it
Next

For $i = 1 To UBound($FileList) - 1 ; For each file in the array
    $FileTime = StringTrimRight(FileGetTime($srcfolder & "\" & $FileList[$i], 0, 1), 6) ; Get its creation date as a string and trim the time off
    If $FileTime <= $newTime Then ; If the file date matches the current date
        FileCopy($srcfolder & "\" & $FileList[$i], "\\msmq.domain.local\IISLogs\WEB01", 1) ; Copy the file to MSMQ
        FileMove($srcfolder & "\" & $FileList[$i], "\\fileshare.domain.local\TraceLogs\WEB-01-W3SVC", 1) ; Move the file
    EndIf
Next

anyone? :)
Link to comment
Share on other sites

Hello skysel,

please wait 24hours before bumbing your topic. :)

Maybe you want to try and check if the dest. file is already there and writeable before you do a FileMove.

Use FileExists and FileOpen for example.

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...