skysel Posted January 26, 2010 Author Share Posted January 26, 2010 Hi, I get this output: Yesterdays Date: 20100125File: C:\Program Files\Microsoft Dynamics CRM\Trace\WEB-01-w3wp-Ttk.Crm.DocumentManagement-20100126-1.log File Date: 20100126File: C:\Program Files\Microsoft Dynamics CRM\Trace\WEB-01-w3wp-Ttk.Crm.FraudPrevention-20100125-1.log File Date: 20100125Got You! WEB-01-w3wp-Ttk.Crm.FraudPrevention-20100125-1.logFile: C:\Program Files\Microsoft Dynamics CRM\Trace\WEB-01-w3wp-Ttk.Crm.FraudPrevention-20100126-1.log File Date: 20100126File: C:\Program Files\Microsoft Dynamics CRM\Trace\WEB-01-w3wp-Ttk.Crm.GetCustomerNumbers-20100125-1.log File Date: 20100125Got You! WEB-01-w3wp-Ttk.Crm.GetCustomerNumbers-20100125-1.logFile: C:\Program Files\Microsoft Dynamics CRM\Trace\WEB-01-w3wp-Ttk.Crm.GetCustomerNumbers-20100126-1.log File Date: 20100126File: C:\Program Files\Microsoft Dynamics CRM\Trace\WEB-01-w3wp-Ttk.Crm.SmartForms-20100125-1.log File Date: 20100125Got You! WEB-01-w3wp-Ttk.Crm.SmartForms-20100125-1.logFile: C:\Program Files\Microsoft Dynamics CRM\Trace\WEB-01-w3wp-Ttk.Crm.SmartForms-20100126-1.log File Date: 20100126File: C:\Program Files\Microsoft Dynamics CRM\Trace\WEB-01-w3wp-wwwroot-20100125-2.log File Date: 20100125Got You! WEB-01-w3wp-wwwroot-20100125-2.logFile: C:\Program Files\Microsoft Dynamics CRM\Trace\WEB-01-w3wp-wwwroot-20100126-1.log File Date: 20100126File: C:\Program Files\Microsoft Dynamics CRM\Trace\WEB-01-w3wp-wwwroot-20100126-2.log File Date: 20100126It appears it should work, but for some strange reason it won't. I'm off from work for today, so we can continue this tomorrow 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... Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 (edited) Every time it outputs "Got you!" that means the match has been made and the file should move! We could do a nice test now to see if the file has been moved by doing this. Wait nevermind, I've just seen this line:If @error > 0 Then FileWriteLine($Logfile,"Error " & @error & " when moving file " & $srcfolder & "\" & $FileList[$i])And now, as there were no errors, we have to assume that there is something wrong with the server. If the files are matched, the date works, then there must be a server fault.Right, so I've commented everything on the script and made a couple of changes. It now logs the file if it wasn't found. Also, if the directory the file is supposed to be moved to doesn't exist, it creates it - just in case.#include <Date.au3> #include <File.au3> $srcfolder = "C:\Program Files\Microsoft Dynamics CRM\Trace" ; Set the source folder $Logfile = "C:\temp\autoit.txt" ; Set the log file $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 FileDelete($Logfile) ; Delete the log file FileWriteLine($Logfile, "Yesterdays Date: " & $newTime) ; Write yesterdays date to it 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 FileWriteLine($Logfile, "File: " & $srcfolder & "\" & $FileList[$i] & " File Date: " & $FileTime & @CRLF) ; Write the log file If $FileTime = $newTime Then ; If the file date matches the current date FileWriteLine($Logfile, "Found file: " & $FileList[$i] & @CRLF) FileMove($srcfolder & "\" & $FileList[$i], "\\server.local\TraceLogs\", 8) ; Move the file If @error Then FileWriteLine($Logfile, "Error " & @error & " when moving file " & $srcfolder & "\" & $FileList[$i]) ; If there is an error, log it Else FileWriteLine($Logfile, "Could not find file: " & $srcfolder & "\" & $FileList[$i] & @CRLF) ; If the file wasn't found, log it EndIf Next 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 27, 2010 Author Share Posted January 27, 2010 Ok this is really weird. Script now moved some files (2-3, but should move more)... The output is logged as: Yesterdays Date: 20100126 File: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-Ttk.Crm.DocumentManagement-20100126-1.log File Date: 20100126 Found file: CRM-WEB-01-w3wp-Ttk.Crm.DocumentManagement-20100126-1.log File: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-Ttk.Crm.DocumentManagement-20100127-1.log File Date: 20100127 Could not find file: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-Ttk.Crm.DocumentManagement-20100127-1.log File: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-Ttk.Crm.FraudPrevention-20100125-1.log File Date: 20100125 Could not find file: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-Ttk.Crm.FraudPrevention-20100125-1.log File: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-Ttk.Crm.FraudPrevention-20100126-1.log File Date: 20100126 Found file: CRM-WEB-01-w3wp-Ttk.Crm.FraudPrevention-20100126-1.log File: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-Ttk.Crm.FraudPrevention-20100127-1.log File Date: 20100127 Could not find file: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-Ttk.Crm.FraudPrevention-20100127-1.log File: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-Ttk.Crm.GetCustomerNumbers-20100125-1.log File Date: 20100125 Could not find file: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-Ttk.Crm.GetCustomerNumbers-20100125-1.log File: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-Ttk.Crm.GetCustomerNumbers-20100126-1.log File Date: 20100126 Found file: CRM-WEB-01-w3wp-Ttk.Crm.GetCustomerNumbers-20100126-1.log File: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-Ttk.Crm.SmartForms-20100125-1.log File Date: 20100125 Could not find file: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-Ttk.Crm.SmartForms-20100125-1.log File: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-Ttk.Crm.SmartForms-20100126-1.log File Date: 20100126 Found file: CRM-WEB-01-w3wp-Ttk.Crm.SmartForms-20100126-1.log File: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-Ttk.Crm.SmartForms-20100127-1.log File Date: 20100127 Could not find file: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-Ttk.Crm.SmartForms-20100127-1.log File: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-wwwroot-20100125-2.log File Date: 20100125 Could not find file: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-wwwroot-20100125-2.log File: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-wwwroot-20100126-1.log File Date: 20100126 Found file: CRM-WEB-01-w3wp-wwwroot-20100126-1.log File: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-wwwroot-20100126-2.log File Date: 20100126 Found file: CRM-WEB-01-w3wp-wwwroot-20100126-2.log File: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-wwwroot-20100126-3.log File Date: 20100126 Found file: CRM-WEB-01-w3wp-wwwroot-20100126-3.log File: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-wwwroot-20100127-1.log File Date: 20100127 Could not find file: C:\Program Files\Microsoft Dynamics CRM\Trace\CRM-WEB-01-w3wp-wwwroot-20100127-1.log Every time it outputs "Got you!" that means the match has been made and the file should move! We could do a nice test now to see if the file has been moved by doing this. Wait nevermind, I've just seen this line: If @error > 0 Then FileWriteLine($Logfile,"Error " & @error & " when moving file " & $srcfolder & "\" & $FileList[$i])And now, as there were no errors, we have to assume that there is something wrong with the server. If the files are matched, the date works, then there must be a server fault. Right, so I've commented everything on the script and made a couple of changes. It now logs the file if it wasn't found. Also, if the directory the file is supposed to be moved to doesn't exist, it creates it - just in case. #include <Date.au3> #include <File.au3> $srcfolder = "C:\Program Files\Microsoft Dynamics CRM\Trace" ; Set the source folder $Logfile = "C:\temp\autoit.txt" ; Set the log file $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 FileDelete($Logfile) ; Delete the log file FileWriteLine($Logfile, "Yesterdays Date: " & $newTime) ; Write yesterdays date to it 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 FileWriteLine($Logfile, "File: " & $srcfolder & "\" & $FileList[$i] & " File Date: " & $FileTime & @CRLF) ; Write the log file If $FileTime = $newTime Then ; If the file date matches the current date FileWriteLine($Logfile, "Found file: " & $FileList[$i] & @CRLF) FileMove($srcfolder & "\" & $FileList[$i], "\\server.local\TraceLogs\", 8) ; Move the file If @error Then FileWriteLine($Logfile, "Error " & @error & " when moving file " & $srcfolder & "\" & $FileList[$i]) ; If there is an error, log it Else FileWriteLine($Logfile, "Could not find file: " & $srcfolder & "\" & $FileList[$i] & @CRLF) ; If the file wasn't found, log it EndIf Next Link to comment Share on other sites More sharing options...
water Posted January 27, 2010 Share Posted January 27, 2010 (edited) Script now moved some files (2-3, but should move more)...According to your log file it should have moved 7 files. How many did it actually move (2 or 3?) and how many should it move (7 or more?)Could you please be as specific as possible? Edited January 27, 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 27, 2010 Share Posted January 27, 2010 Urgh, not this problem again.@water, do you agree with me that this has to be a server issue more than an "us" being bad coders? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
skysel Posted January 27, 2010 Author Share Posted January 27, 2010 Hah, I figured out what was wrong! On the FileMove function, I've added flag 1 (means overwrite existing files, etc). And now the script works great... go figure? Don't know what and why but it is working as it should. Thank you both for your extensive help! Link to comment Share on other sites More sharing options...
James Posted January 27, 2010 Share Posted January 27, 2010 (edited) Hah, I figured out what was wrong! On the FileMove function, I've added flag 1 (means overwrite existing files, etc). And now the script works great... go figure? Don't know what and why but it is working as it should. Thank you both for your extensive help! Edited January 27, 2010 by JamesBrooks Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
water Posted January 27, 2010 Share Posted January 27, 2010 I agree whole-heartedly! 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 27, 2010 Author Share Posted January 27, 2010 James, is it that bad? Yeah I really don't know why the flag 1 on FileMove - because when the files moved they couldn't exist already on destination folder so files should get moved without overwrite flag! It really puzzles me Link to comment Share on other sites More sharing options...
James Posted January 27, 2010 Share Posted January 27, 2010 (edited) James, is it that bad? Yeah I really don't know why the flag 1 on FileMove - because when the files moved they couldn't exist already on destination folder so files should get moved without overwrite flag! It really puzzles me It's kind of annoying. A tiny issue like that took three of us hours to fix.I'd either completely ignore the flag or set it or set it to 9:1 = overwrite existing files 8 = Create destination directory structure if it doesn't exist (See Remarks).So 1+8 = Create/Overwrite if it doesn't exist Edited January 27, 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 27, 2010 Author Share Posted January 27, 2010 Haha, mabye that feature should be implemented in the next release of auto-it .. combining flags like you said.. 1+8=9 Link to comment Share on other sites More sharing options...
James Posted January 27, 2010 Share Posted January 27, 2010 Haha, mabye that feature should be implemented in the next release of auto-it .. combining flags like you said.. 1+8=9 What? You already can. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
water Posted January 27, 2010 Share Posted January 27, 2010 Haha, mabye that feature should be implemented in the next release of auto-it .. combining flags like you said.. 1+8=9 You can already use it. Set the flag to 9 and it works! 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 27, 2010 Share Posted January 27, 2010 (edited) I get off this topic . Otherwise I fear to get brain cancer I need all my neurons for the Active Directory UDF (see signature). Edited January 27, 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...
skysel Posted January 27, 2010 Author Share Posted January 27, 2010 Oops, I didn't know that you can actualy combine flags... . Again, thank you both for your help! 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