skysel Posted January 26, 2010 Author Share Posted January 26, 2010 Nope, neither water's script is not working. We're missing something here... Complete script looks like this now: #Include <File.au3> #include <Array.au3> #include <Date.au3> $srcfolder = "C:\Program Files\Microsoft Dynamics CRM\Trace" $FileList = _FileListToArray($srcfolder) For $i = 1 To UBound($FileList) - 1 $FileTime = FileGetTime($srcfolder & "\" & $FileList[$i], 0) If $FileTime[0] = @YEAR And $FileTime[1] = @MON And $FileTime[2] = @MDAY Then FileMove($srcfolder & "\" & $FileList[$i], "\\server.local\TraceLogs\CRM-WEB-01") EndIf Next For $i = 1 To UBound($FileList) - 1 $FileTime = FileGetTime($srcfolder & "\" & $FileList[$i], 0) If $FileTime[0] & "/" & $FileTime[1] & "/" & $FileTime[2] = _DateAdd("D", -1, _NowCalcDate()) Then FileMove($srcfolder & "\" & $FileList[$i], "\\server.local\TraceLogs\CRM-WEB-01") EndIf Next First part works flawlessly, second however still doesn't :-) Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 If $FileTime[0] & "/" & $FileTime[1] & "/" & $FileTime[2] = _DateAdd("D", -1, _NowCalcDate()) ThenI'm sure that wont work for the simple reason you're comparing the wrong part. That doesn't take into account month changes or years. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
water Posted January 26, 2010 Share Posted January 26, 2010 Does this code work? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted January 26, 2010 Share Posted January 26, 2010 (edited) I get the feeling that I'm blind, deaf and stupid (today) Why should I take into account month changes or years? This is calculated by _DateAdd. It returns a string of yesterdays date which is compared against the string of the filedate (both in the same format). Edited January 26, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 I'm so confused it's ridiculous.Both of our scripts should work just fine (you weren't comparing the wrong parts, I just read it wrong )The problem has to be somewhere else. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
water Posted January 26, 2010 Share Posted January 26, 2010 One thing that took some time for me to understand was that _FileGetTime needs the THIRD parameter to be set to 1 to return the date as a string. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 One thing that took some time for me to understand was that _FileGetTime needs the THIRD parameter to be set to 1 to return the date as a string.I've mentioned this in the first page. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
water Posted January 26, 2010 Share Posted January 26, 2010 (edited) Yes, but in your post you've set parameter #2 (Flag to indicate which timestamp) so the date was still returned as an array. Edited January 26, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 (edited) I know why it doesn't work.FileGetTime returns YYYYMMDDHHMMSS in string mode. So...#Include <File.au3> #include <Date.au3> $srcfolder = "C:\Program Files\Microsoft Dynamics CRM\Trace" $FileList = _FileListToArray($srcfolder) $arTime = StringSplit(_DateAdd("D", -1, _NowCalcDate()), "/") Dim $newTime For $a = 1 To UBound($arTime) - 1 $newTime &= $arTime[$a] Next For $i = 1 To UBound($FileList) - 1 $FileTime = FileGetTime($srcfolder & "\" & $FileList[$i], 0, 1) ConsoleWrite(StringTrimRight($FileTime, 6) & @CRLF) If StringTrimRight($FileTime, 6) = $newTime Then ConsoleWrite("Found you!" & @CRLF) FileMove($srcfolder & "\" & $FileList[$i], "\\server.local\TraceLogs\") EndIf NextYes, the first loop could be done better but it works. Edited January 26, 2010 by JamesBrooks Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
skysel Posted January 26, 2010 Author Share Posted January 26, 2010 Just tested it. I've only removed ConsoleWrite line. Still not working. First part - moving files created today works ok, second part files created yesterday/older doesn't work. Files created yesterday are not write-protected, I have full permissions to move those files. I know why it doesn't work. FileGetTime returns YYYYMMDDHHMMSS in string mode. So... #Include <File.au3> #include <Date.au3> $srcfolder = "C:\Program Files\Microsoft Dynamics CRM\Trace" $FileList = _FileListToArray($srcfolder) $arTime = StringSplit(_DateAdd("D", -1, _NowCalcDate()), "/") Dim $newTime For $a = 1 To UBound($arTime) - 1 $newTime &= $arTime[$a] Next For $i = 1 To UBound($FileList) - 1 $FileTime = FileGetTime($srcfolder & "\" & $FileList[$i], 0, 1) ConsoleWrite(StringTrimRight($FileTime, 6) & @CRLF) If StringTrimRight($FileTime, 6) = $newTime Then ConsoleWrite("Found you!" & @CRLF) FileMove($srcfolder & "\" & $FileList[$i], "\\server.local\TraceLogs\") EndIf NextYes, the first loop could be done better but it works. Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 Just tested it. I've only removed ConsoleWrite line. Still not working. I tried it myself, it worked fine for me. What the hell. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
skysel Posted January 26, 2010 Author Share Posted January 26, 2010 Ok just for the sake of script's health I'm posting it again. I've just attached your part of the code. #Include <File.au3> #include <Array.au3> #include <Date.au3> $srcfolder = "C:\Program Files\Microsoft Dynamics CRM\Trace" $FileList = _FileListToArray($srcfolder) For $i = 1 To UBound($FileList) - 1 $FileTime = FileGetTime($srcfolder & "\" & $FileList[$i], 0) If $FileTime[0] = @YEAR And $FileTime[1] = @MON And $FileTime[2] = @MDAY Then FileMove($srcfolder & "\" & $FileList[$i], "\\server.local\TraceLogs") EndIf Next $FileList = _FileListToArray($srcfolder) $arTime = StringSplit(_DateAdd("D", -1, _NowCalcDate()), "/") Dim $newTime For $a = 1 To UBound($arTime) - 1 $newTime &= $arTime[$a] Next For $i = 1 To UBound($FileList) - 1 $FileTime = FileGetTime($srcfolder & "\" & $FileList[$i], 0, 1) ConsoleWrite(StringTrimRight($FileTime, 6) & @CRLF) If StringTrimRight($FileTime, 6) = $newTime Then FileMove($srcfolder & "\" & $FileList[$i], "\\server.local\TraceLogs") EndIf Next Link to comment Share on other sites More sharing options...
water Posted January 26, 2010 Share Posted January 26, 2010 I tried it myself (but without FileMove), it worked fine for me as well.What does "doesn't work" mean? Do you get any error messages?Are the files copied to the target?I'm not sure if AutoIt supports UNC notation (\\server.local\TraceLogs\). Can you try to move the files to - lets say - C:\temp?Can you uncomment or reinsert the lineConsoleWrite("Found you!" & @CRLF)so we know we got the date comparison right? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
skysel Posted January 26, 2010 Author Share Posted January 26, 2010 (edited) Hi water, by doesn't work I mean: - No error messages - Files are not copied to the target - AutoIt supports UNC (Check the first part of the script, this very first part works without problems for few days already on a Win2k3 server) - After reinsertion of ConsoleWrite line, I still get no messages whatsoever. I tried it myself (but without FileMove), it worked fine for me as well. What does "doesn't work" mean? Do you get any error messages?Are the files copied to the target?I'm not sure if AutoIt supports UNC notation (\\server.local\TraceLogs\). Can you try to move the files to - lets say - C:\temp?Can you uncomment or reinsert the lineConsoleWrite("Found you!" & @CRLF)so we know we got the date comparison right? Edited January 26, 2010 by skysel Link to comment Share on other sites More sharing options...
water Posted January 26, 2010 Share Posted January 26, 2010 Another try I extended the example that works for me to display yesterday's date and the date of all files plus any error message that might occur when moving the file (maybe the target disk is full or the target directory isn't created yet ...)#include <Date.au3> #include <array.au3> #include <file.au3> $srcfolder = "C:\Program Files\Microsoft Dynamics CRM\Trace" $FileList = _FileListToArray($srcfolder) $arTime = StringSplit(_DateAdd("D", -1, _NowCalcDate()), "/") Dim $newTime For $a = 1 To UBound($arTime) - 1 $newTime &= $arTime[$a] Next ConsoleWrite("Yesterdays Date: " & $newtime & @CRLF) For $i = 1 To UBound($FileList) - 1 $FileTime = FileGetTime($srcfolder & "\" & $FileList[$i], 0, 1) ConsoleWrite("File: " & $srcfolder & "\" & $FileList[$i] & " File Date: " & StringTrimRight($FileTime, 6) & @CRLF) If StringTrimRight($FileTime, 6) = $newTime Then ConsoleWrite("Got You! " & $FileList[$i] & @CRLF) FileMove($srcfolder & "\" & $FileList[$i], "\\server.local\TraceLogs\") If @error > 0 Then MsgBox(0,"","Error " & @error & " when moving file " & $srcfolder & "\" & $FileList[$i]) EndIf NextCould you give it a try and report the results from the SciTe console? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
skysel Posted January 26, 2010 Author Share Posted January 26, 2010 (edited) This time I've only used your part of script and executed it on the server. Script runs. No error messages. No nothing. Still doesn't move the files. Target directory has 60GB of free space. I cannot run the script from the editor, since I am not allowed to install any additional software to the server. Could it be replaced by MsgBox()? Edited January 26, 2010 by skysel Link to comment Share on other sites More sharing options...
water Posted January 26, 2010 Share Posted January 26, 2010 But the SciTE console should return a lot of information. How about that? Or do you compile the script and then run the exe? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
skysel Posted January 26, 2010 Author Share Posted January 26, 2010 But the SciTE console should return a lot of information. How about that? Or do you compile the script and then run the exe?Read the post above I must compile and then run as exe. Link to comment Share on other sites More sharing options...
water Posted January 26, 2010 Share Posted January 26, 2010 Sorry, missed that line. I changed the script so that all messages are written to a log file C:\temp\autoit.txt Could you please post this log file? #include <Date.au3> #include <array.au3> #include <file.au3> $srcfolder = "C:\Program Files\Microsoft Dynamics CRM\Trace" $Logfile = "C:\temp\autoit.txt" $FileList = _FileListToArray($srcfolder) $arTime = StringSplit(_DateAdd("D", -1, _NowCalcDate()), "/") Dim $newTime For $a = 1 To UBound($arTime) - 1 $newTime &= $arTime[$a] Next FileDelete($Logfile) FileWriteLine($Logfile,"Yesterdays Date: " & $newtime) For $i = 1 To UBound($FileList) - 1 $FileTime = FileGetTime($srcfolder & "\" & $FileList[$i], 0, 1) FileWriteLine($Logfile,"File: " & $srcfolder & "\" & $FileList[$i] & " File Date: " & StringTrimRight($FileTime, 6)) If StringTrimRight($FileTime, 6) = $newTime Then FileWriteLine($Logfile,"Got You! " & $FileList[$i]) FileMove($srcfolder & "\" & $FileList[$i], "\\server.local\TraceLogs\") If @error > 0 Then FileWriteLine($Logfile,"Error " & @error & " when moving file " & $srcfolder & "\" & $FileList[$i]) EndIf Next My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 This is ridiculous! The last script I posted worked fine when I tried moving files from a sub-directory on my Desktop to my Desktop. skysel, run waters script, post the output and let's see what the hell is going on... Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now