Jump to content

jayfry

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by jayfry

  1. Hello, I'm trying to use _FileListToArrayRec to filter out my results. I'm able to get it to include *.url, and exclude folders starting with MSN however if i try to get it to Also exclude folders beginning with Microsoft, it includes everything again. This currently returns the file path for all files that have *url in the name, and are not part of the MSN folder. $aArray = _FileListToArrayRec($sAutoItDir, "*.url||MSN*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) This is currently not working $aArray = _FileListToArrayRec($sAutoItDir, "*.url||MSN*||Microsoft*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) I can see in the _FileListToArrayRec doc that "Multiple filters must be separated by ";"", but i can't figure out how to format it. Any help would be appreciated.
  2. to round this out in case anyone wants to use it later Here's my full code. #Include <File.au3> #Include <Array.au3> $sAutoItDir = "C:\Users\Jonathan\Desktop\DEV\Store Bookmarks" ;This buils out the Dirs to get bookmarks from. It recurselivy returns files that end in .url. $aArray = _FileListToArrayRec($sAutoItDir, "*.url", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) ;This takes the files provided by $aArray, Reads them line by line, and for lines that start with URL, it writes them to $aFinal local $aFinal[0] for $i = 1 to $aArray[0] $file2 = $aArray[$i] FileOpen($file2,0) For $j = 1 to _FileCountLines($file2) $line = FileReadLine($file2, $j) If StringLeft($line, 3) = "URL" Then _ArrayAdd($aFinal, $line) EndIf Next Next _ArrayDisplay($aFinal) i'm super happy. The documentation for this language is great.
  3. I figured out I was initializing my array inside my loop (DOH). This works for me. local $aFinal[0] for $i = 1 to $aArray[0] $file2 = $aArray[$i] FileOpen($file2,0) For $j = 1 to _FileCountLines($file2) $line = FileReadLine($file2, $j) If StringLeft($line, 3) = "URL" Then _ArrayAdd($aFinal, $line) EndIf Next Next _ArrayDisplay($aFinal)
  4. Thank you for pointing that out. I think this fixes that issue. for $i = 1 to $aArray[0] $file2 = $aArray[$i] FileOpen($file2,0) For $j = 1 to _FileCountLines($file2) $line = FileReadLine($file2, $j) If StringLeft($line, 3) = "URL" Then FileWrite($file, $line&@CRLF) EndIf Next Next Could you point me to which help file will show me how to add the result into another array, i'd rather not save this to a file if I don't have to. I Tired _ArrayAdd but i'm not getting it. I think it's the right direction tho. Edit. Adding wrong code at first.
  5. Thank you for pointing that out. I think this fixes that issue. for $i = 1 to $aArray[0] for $j = 1 to _FileCountLines($aArray[$i]) $line = FileReadline($aArray[$i],$j) If StringLeft($line, 3) = "URL" Then FileWrite($file, $line&@CRLF) EndIf Next Next Could you point me to which help file will show me how to add the result into another array, i'd rather not save this to a file if I don't have to. I Tired _ArrayAdd but i'm not getting it. I think it's the right direction tho.
  6. So my output gave me more URLs than I wanted, and I stumbled across stringleft. I'm now using the following to sort go through my array and only take the lines that start with URL. #Include <File.au3> #Include <Array.au3> $fileout = "C:\Users\Jonathan\Desktop\DEV\CreateFile\Good Stuff\out.txt" $sAutoItDir = "C:\Users\Jonathan\Desktop\DEV\Store Bookmarks" if FileExists($fileout) then FileDelete($fileout) $file = FileOpen($fileout, 1) ;This buils out the Dirs to get bookmarks from. It recurselivy returns files that end in .url. $aArray = _FileListToArrayRec($sAutoItDir, "*.url", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) ;This takes the file paths provided by the _FilelisttoarrayRec above and combines all the files into 1 file. for $i = 1 to $aArray[0] for $j = 1 to _FileCountLines($aArray[$i]) $line = FileReadline($aArray[$i],$j) If StringLeft($line, 3) = "URL" Then FileWrite($file, $line&@CRLF) EndIf Next Next Let me know if this is good or not
  7. Hello, First this form is great, I've gotten so much done today with just the help files and examples here. So please if you know a help file I can use, let me know. _ArrayExtract is what i'm thinking will work. What i'm doing: I'm getting a list of files whose name contains ".url", putting the full path to an Array, then i'm taking those files and joining all the files into 1 file. What I want to do now, is from that master file I created, I want to extract only lines whose it contains "URL". #Include <File.au3> #Include <Array.au3> $fileout = "C:\Users\Good Stuff\out.txt" $sAutoItDir = "C:\Users\Store Bookmarks" if FileExists($fileout) then FileDelete($fileout) $file = FileOpen($fileout, 1) $aArray = _FileListToArrayRec($sAutoItDir, "*.url", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) for $i = 1 to $aArray[0] $data = FileRead($aArray[$i]) FileWrite($file, "-------------------- File: "&$aArray[$i]&"--------------------------------"&@crlf) FileWrite($file, $data&@CRLF) Next ; Define a variable to pass to _FileReadToArray. Local $aArray = 0 If Not _FileReadToArray($fileout, $aArray, 0) Then MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file. EndIf ; Display the array in _ArrayDisplay. _ArrayDisplay($aArray) ;Here I want to create a variable and set it to the value of an array whose consists of only lines that have URL, extracted from the master file i loaded into an array. ;$extractedArray = _ArrayExtract($aArray, "URL=", "URL=") ;_ArrayDisplay($extractedArray) FileClose($file) ;ShellExecute($fileout) Everything works the way I want it to, up until extracting lines whose it contains URL from the "master file" array I made. Hoping someone can point me in the right direction. Also I just started autoit today so if you see other issues please feel free to point them out to me.
×
×
  • Create New...