Myke Posted October 6, 2005 Share Posted October 6, 2005 Hello, I am new to Autoit and Im not sure where to start. I have a project that I have been working on that I need a little help with. I have a piece of software that writes log files to a directory on the C Drive. It names the files for the day of the month that the file is created. For example log01.txt, log02.txt, log03.txt ..... log29.txt, log30.txt It does this through the end of the month. Then it starts over again and overwrites the previous month. We need to keep these records for historical data. What I need to do is first check to see if a folder exists on a networked drive that corresponds with the year, then a subfolder for month then a subfolder using the computername. If those folders do not exist then create them. Then I need to place the log file for that particular day inside the corresponding folder on the networked drive. Any help would be appreciated. Link to comment Share on other sites More sharing options...
Confuzzled Posted October 6, 2005 Share Posted October 6, 2005 You may find the following commands in the help file of use: FileFindFirstFile - find the first file in a folder matching (can use wildcards such as log*.txt in your case) FileFindNextFile - find next one FileGetTime - to extract the date information for a file FileMove - moves and renames files @ComputerName - Computer's network name @MDAY - day of month @YEAR - four digit year Suggestion: For sorting purposes, can I recommend YYYYMMDD for your date storage Good luck! Link to comment Share on other sites More sharing options...
seandisanti Posted October 7, 2005 Share Posted October 7, 2005 (edited) You may find the following commands in the help file of use:FileFindFirstFile - find the first file in a folder matching (can use wildcards such as log*.txt in your case)FileFindNextFile - find next oneFileGetTime - to extract the date information for a fileFileMove - moves and renames files@ComputerName - Computer's network name@MDAY - day of month@YEAR - four digit yearSuggestion: For sorting purposes, can I recommend YYYYMMDD for your date storageGood luck!and dont' forget FileExists()_FileWriteLog()FileCopy()/FileMove() ; whether you want to keep a copy on the C:\ or move the file to the network shareDirCreate()DirCopy()***edit***i didn't explain each function because the names seemed kind of self explanatory and full details and examples for each are in the help file Edited October 7, 2005 by cameronsdad Link to comment Share on other sites More sharing options...
Myke Posted October 7, 2005 Author Share Posted October 7, 2005 (edited) Im having issues creating a new folder on the mapped drive. This works ok on my computer but it wont create a directory on the server. Are there any known issues with creating a directory on Novell servers? $answer = MsgBox(4, "Data Backup", "This Script will backup the Data. Continue?") If $answer = 7 Then MsgBox(0, "Quit", "Remember to backup your data!") Exit EndIf If FileExists("Z:\"&@YEAR&"\month"&@MON&"\"&@ComputerName&"\") Then FileCopy("C:\Program Files\APPfolder\Log\log"&@MDAY&".*","Z:\"&@YEAR&"\month"&@MON&"\"&@ComputerName&"\*.*") Else DirCreate("Z:\"&@YEAR&"\month"&@MON&"\"&@ComputerName&"\") FileCopy("C:\Program Files\APPfolder\Log\log"&@MDAY&".*","Z:\"&@YEAR&"\month"&@MON&"\"&@ComputerName&"\*.*") EndIfThanks for everyones help. Edited October 7, 2005 by Myke Link to comment Share on other sites More sharing options...
Myke Posted October 7, 2005 Author Share Posted October 7, 2005 Well I found out how to post code in a separate window. Link to comment Share on other sites More sharing options...
seandisanti Posted October 7, 2005 Share Posted October 7, 2005 Well I found out how to post code in a separate window.step 2 is to find out how to edit a post.... just giving you a hard time there.the script provided worked fine on my computer after a couple of little changes, purely aesthetic though...make sure that the user running the program has permissions to create directories on the shared drive, if not, you're going to have to use RunAsSet() to run your compiled script from another script, or setup your script to run as a different user with permissions to do what you want. here's my code...$answer = MsgBox(4, "Data Backup", "This Script will backup the Data. Continue?") If $answer = 7 Then MsgBox(0, "Quit", "Remember to backup your data!") Exit EndIf $mapped = "Z:\"&@YEAR&"\month"&@MON&"\"&@ComputerName&"\" $local = "C:\"&@YEAR&"\month"&@MON&"\"&@ComputerName&"\" If FileExists($mapped) Then FileCopy($local & "*.*", $mapped) Else DirCreate($mapped) FileCopy($local & "*.*",$mapped) EndIf Link to comment Share on other sites More sharing options...
Myke Posted October 7, 2005 Author Share Posted October 7, 2005 step 2 is to find out how to edit a post.... just giving you a hard time there. :"> Yeah.... I figured that one out too.Thanks for the tip on setting up the Var in the script.Ok.. heres the thing. I have full Admin rights to the Novell servers. When I tried to run the script with $mapped set to my Z: drive it did not create the directory. This was a Novell Server. $mapped = "Z:\test1\"&@YEAR&"\month"&@MON&"\"&@ComputerName&"\" $local = "C:\test\" If FileExists($mapped) Then FileCopy($local & "\log" & @MDAY & ".txt",$mapped & "\*.*") Else DirCreate($mapped) FileCopy($local & "\log" & @MDAY & ".txt",$mapped & "\*.*") EndIfWhen I ran the script with the W: drive mapped it created the directory. The W: drive is mapped to a windows 2003 server.$mapped = "W:\test1\"&@YEAR&"\month"&@MON&"\"&@ComputerName&"\" $local = "C:\test\" If FileExists($mapped) Then FileCopy($local & "\log" & @MDAY & ".txt",$mapped & "\*.*") Else DirCreate($mapped) FileCopy($local & "\log" & @MDAY & ".txt",$mapped & "\*.*") EndIfThe only difference was the drive letter and of course the type of server. Has anyone ever seen this before? Thanks again for your help. Link to comment Share on other sites More sharing options...
/dev/null Posted October 7, 2005 Share Posted October 7, 2005 The only difference was the drive letter and of course the type of server. Has anyone ever seen this before? Thanks again for your help.add the following code to your script right AFTER DirCreate() and post the results (content of the clipboard).$lastError = DllCall("kernel32.dll", "int", "GetLastError")ClipPut("Error: " & $lastError[0])CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Myke Posted October 7, 2005 Author Share Posted October 7, 2005 (edited) The content of the clipboard was: Error: 3 Is there a place to lookup error codes? This one doesn't seem very helpful........ Edited October 7, 2005 by Myke Link to comment Share on other sites More sharing options...
/dev/null Posted October 7, 2005 Share Posted October 7, 2005 The content of the clipboard was:Error: 3Is there a place to lookup error codes?This one doesn't seem very helpful........According to the error code list HERE, the system was not able to find the path. Try to map your novell file share to another drive letter.CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * 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