AutoMT Posted November 13, 2007 Share Posted November 13, 2007 Hi there, I'm writing a script that will be placed on all the computers in a network to monitor the size of a folder on a drive. The folder is usually something likeD:\FIFO\13\2007_11_14\18which isD:\FIFO\[channel]\[year_month_date]\[hour]This is the line I'm using:$point1 = DirGetSize("D:\FIFO\13\" & @year & "_" & @MON & "_" & @MDAY & "\" & @HOUR)However, the number in bold, 13, is sometimes a different number on certain machines, and rather than write a separate script for each machine, I'd like to know if there's any way I can make it search in any folder under the D:\FIFO directory. Link to comment Share on other sites More sharing options...
Nahuel Posted November 13, 2007 Share Posted November 13, 2007 If there's only ONE folder under FIFO, then try this: #include <File.au3> $FileList=_FileListToArray ( "D:\FIFO\","",2) $point1 = DirGetSize($FileList[1] & @year & "_" & @MON & "_" & @MDAY & "\" & @HOUR) Link to comment Share on other sites More sharing options...
AutoMT Posted November 13, 2007 Author Share Posted November 13, 2007 Sorry - I forgot to say, there are four different folders under FIFO... Link to comment Share on other sites More sharing options...
Nahuel Posted November 14, 2007 Share Posted November 14, 2007 (edited) -edit- This should work: Global $FolderName #include <File.au3> $FileList=_FileListToArray ( "D:\FIFO\","*",2) For $i=1 To $FileList[0] $TestDir=_FileListToArray ("D:\FIFO\" & $FileList[$i],"*",2) If Not IsArray($TestDir) Then ContinueLoop For $a=1 To $TestDir[0] If StringInStr($TestDir[$a],@year & "_" & @MON & "_" & @MDAY ) Then $FolderName=$FileList[$i];$FileList[$i] is the name of the folder you want ExitLoop(2) EndIf Next Next MsgBox(0,"",$FolderName) $point1 = DirGetSize("D:\FIFO\" & $FolderName & "\" & @year & "_" & @MON & "_" & @MDAY & "\" & @HOUR) MsgBox(0,"",$point1) Edited November 14, 2007 by Nahuel Link to comment Share on other sites More sharing options...
AutoMT Posted November 14, 2007 Author Share Posted November 14, 2007 -edit- This should work:The first thing you had up worked a treat, this thing: #include <File.au3> $FileList=_FileListToArray ( "D:\FIFO\","*",2) For $i=1 To $FileList[0] $SplitPath=StringSplit($FileList[$i],"\") $FolderName=$SplitPath[$SplitPath[0]] If StringRegExp($FolderName,"(i?)[^a-z][0-9]") Then $folder=$FolderName ExitLoop EndIf Next However I've found a few computers that have a FIFO directory on their C drive instead of D. I'm trying to make it so the script will check the C drive if it cannot find anything on the D drive - by pretty much duplicating that code under a different function except changing it to C:\FIFO instead of D. However I don't know if this is the right thing to do because I am getting this error: >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\taylorsu\Desktop\AlertStage.au3" C:\Documents and Settings\taylorsu\Desktop\AlertStage.au3 (63) : ==> Subscript used with non-Array variable.: For $i=1 To $FileList[0] For $i=1 To $FileList^ ERROR >Exit code: 1 Time: 8.864Since I'm not entirely sure what the code is doing, I can't really figure out what the problem is (I'm new at this :/). Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 14, 2007 Share Posted November 14, 2007 The first thing you had up worked a treat, this thing: However I've found a few computers that have a FIFO directory on their C drive instead of D. I'm trying to make it so the script will check the C drive if it cannot find anything on the D drive - by pretty much duplicating that code under a different function except changing it to C:\FIFO instead of D. However I don't know if this is the right thing to do because I am getting this error: Since I'm not entirely sure what the code is doing, I can't really figure out what the problem is (I'm new at this :/). You just need a test to make sure the search was successful before wading into the array: #include <File.au3> $FileList = _FileListToArray("D:\FIFO\", "*", 2) If @error Then MsgBox(16, "Error", "No files listed") Else For $i = 1 To $FileList[0] $SplitPath = StringSplit($FileList[$i], "\") $FolderName = $SplitPath[$SplitPath[0]] If StringRegExp($FolderName, "(i?)[^a-z][0-9]") Then $folder = $FolderName ExitLoop EndIf Next EndIf Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
AutoMT Posted November 14, 2007 Author Share Posted November 14, 2007 You just need a test to make sure the search was successful before wading into the array:That's awesome, it works great now! 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