xZZTx Posted May 29, 2009 Share Posted May 29, 2009 (edited) Yo; anyways...ive been trying to make a simple directory crawler that would filewriteline() about what files it foundthis is my try at it $Dir = @ScriptDir $Dr1 = $Dir $A = FileFindFirstFile("*.*") while 1 $B = FileFindNextFile($A) $C = StringSplit(FileGetLongName($B,1),".") If @error = 0 Then If $C[0] >= 2 Then If $C[2] = "zzt" Or $C[2] = "au3" Then Else FileWriteLine("text.zzt",$Dir&"\"&$B) EndIf EndIf EndIf If $C[0] = 1 And $B = Not "" Then $Dir = $Dir&"\"&$B EndIf If $B = "" Then If $Dir = $Dr1 Then ExitLoop EndIf $A = FileFindFirstFile($Dir&"\*.*") $Dr1 = $Dir $B = "" EndIf WEndthe text.zzt was the file it was writeing to as you can seeit works if it only has 1 folder to another...IEC:\1\1.txt C:\1\2\2.txt C:\1\2\3\3.txtthat would work but if any of them have a 2nd Dir it fails...any ideas?also i know i coulda just done If not yada yada yada but im lazzy so i just left teh big piles of if'sEDIT!!!Woot!! I Solved itexpandcollapse popup$Dir = @ScriptDir $Dr1 = $Dir $Dr2 = 0 dim $Dr[100] $A = FileFindFirstFile("*.*") while 1 $B = FileFindNextFile($A) $C = StringSplit(FileGetLongName($B,1),".") If @error = 0 Then If $C[0] >= 2 Then If $C[2] = "zzt" Or $C[2] = "au3" Then Else FileWriteLine("text.zzt",$Dir&"\"&$B) EndIf EndIf EndIf If $C[0] = 1 And $B = Not "" Then If $Dr2 = 1 Then $Dr[0] += 1 $Dr[$Dr[0]] = $Dr3&"\"&$B Else $Dr3 = $Dir $Dr2 = 1 $Dir = $Dir&"\"&$B EndIf EndIf If $B = "" Then $Dr2 = 0 If $Dir = $Dr1 Then If $Dr[0] = Not 0 Then $Dir = $Dr[$Dr[0]] $Dr[0] -= 1 $Dr2 = 0 Else ExitLoop EndIf EndIf $A = FileFindFirstFile($Dir&"\*.*") $Dr1 = $Dir $B = "" EndIf WEndnow its time to optimize it Edit Again That was the best i could do lol Edited May 29, 2009 by xZZTx Sorry For Any Spelling / Grammar Errors I May Make.... I Failed English Wayyyy To Many Times.. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 29, 2009 Moderators Share Posted May 29, 2009 xZZTx, Try searching for "recursive file search". There are plenty of examples out there. I would do it for you , but I too am feeling a bit lazy........ ;-) M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
xZZTx Posted May 29, 2009 Author Share Posted May 29, 2009 Well i got it to work now...so if any 1 needs it; good luck Sorry For Any Spelling / Grammar Errors I May Make.... I Failed English Wayyyy To Many Times.. Link to comment Share on other sites More sharing options...
RAMMRODD Posted August 3, 2009 Share Posted August 3, 2009 Just what I was looking for, Ill be sure to add you in as the brains behind this part of my script. 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