FuryCell Posted May 28, 2005 Share Posted May 28, 2005 (edited) here are the udfs i just created:_FileList();=============================================================================== ; ; Description: lists all files and folders in a specified path (Similar to using Dir with the /B Switch) ; Syntax: _FileList($sPath) ; Parameter(s): $sPath = Path to generate filelist for ; Requirement(s): None ; Return Value(s): On Success - Returns an array containing the list of files and folders in the specified path ; On Failure - Returns an empty string "" if no files are found and sets @Error to 1 if the path is not found ; Author(s): SolidSnake <MetalGearX91@Hotmail.com> ; Note(s): The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of Files\Folders returned ; $array[1] = 1st File\Folder ; $array[2] = 2nd File\Folder ; $array[3] = 3rd File\Folder ; $array[n] = nth File\Folder ;================================================================================ _RegValueList();=============================================================================== ; ; Description: lists the names of all values in a specified key ; Syntax: _RegValueList($sKey) ; Parameter(s): $sKey = Key to generate valuelist for ; Requirement(s): None ; Return Value(s): On Success - Returns an array containing the list of values in the specified path ; On Failure - Returns an empty string "" if no values are found and sets @Error to 1 if the key is not found ; Author(s): SolidSnake <MetalGearX91@Hotmail.com> ; Note(s): The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of values returned ; $array[1] = 1st value ; $array[2] = 2nd value ; $array[3] = 3rd value ; $array[n] = nth value ;=============================================================================== _RegKeyList();=============================================================================== ; ; Description: lists all subkeys in a specified key ; Syntax: _RegKeyList($sKey) ; Parameter(s): $sKey = Key to generate keylist for ; Requirement(s): None ; Return Value(s): On Success - Returns an array containing the list of subkeys in the specified path ; On Failure - Returns an empty string "" if no Keys are found and sets @Error to 1 if the key is not found ; Author(s): SolidSnake <MetalGearX91@Hotmail.com> ; Note(s): The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of Keys returned ; $array[1] = 1st Key ; $array[2] = 2nd Key ; $array[3] = 3rd Key ; $array[n] = nth Key ;===============================================================================Enjoy Edit:See Post Below to download new version. Edited May 30, 2005 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
FuryCell Posted May 29, 2005 Author Share Posted May 29, 2005 More than 24 hours and still no reply? HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
Helge Posted May 29, 2005 Share Posted May 29, 2005 Tested on Windows 2000 (SP4) and they all seem to work perfectly.I said "seem to work", because I'm currently on a restricted computer,so I'm unable to enter the registry to manually check the keys and values.Anyway.. Nice work SolidSnake ! Link to comment Share on other sites More sharing options...
Helge Posted May 29, 2005 Share Posted May 29, 2005 Just an idea..What about adding another parameter to _FileList where you coulddecide if it should return files or folders (or both) ... ?FileList("c:\",0); Default (shows files and folders) FileList("c:\",1); Just files FileList("c:\",2;; Just foldersWhat do you think ? Link to comment Share on other sites More sharing options...
layer Posted May 30, 2005 Share Posted May 30, 2005 (edited) Arghh... I was going to create a filelist type function, and then make another that would -- well, I'll make it first and then tell you, if I ever find the time!!! AHH BTW, Good work! Edited May 30, 2005 by layer FootbaG Link to comment Share on other sites More sharing options...
FuryCell Posted May 30, 2005 Author Share Posted May 30, 2005 (edited) Just an idea..What about adding another parameter to _FileList where you coulddecide if it should return files or folders (or both) ... ?FileList("c:\",0); Default (shows files and folders) FileList("c:\",1); Just files FileList("c:\",2;; Just foldersWhat do you think ?<{POST_SNAPBACK}>I would like to do that but don't know of anyway to tell files and folders apart. If anyone knows and would like to help me out feel free.anyway Thanks for the feedback Layer and Helge Edited June 8, 2005 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
/dev/null Posted May 30, 2005 Share Posted May 30, 2005 I would like to do that but don't know of anyway to tell files and folders apart. FileGetAttrib() ?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...
layer Posted May 30, 2005 Share Posted May 30, 2005 (edited) here is a function i just made to determine that! Func FileOrFolder($path) Local $len = StringLen($path) If StringMid($path, $len) = "\" Then MsgBox(0, "Folder", $path & " is a folder.") Else MsgBox(0, "File", $path & " is a file.") EndIf EndFunc ;==>FileOrFolder FileOrFolder("C:\Program Files\AutoIt3\AutoIt3.exe") FileOrFolder("C:\")good luck! EDIT: Also, FileGetAttrib would work, but my function looks so much cooler! Don't ya think Edited May 30, 2005 by layer FootbaG Link to comment Share on other sites More sharing options...
Helge Posted May 30, 2005 Share Posted May 30, 2005 Also, how can the user tell apart a folder and a file ? One way of doing it is to add a "\" at the end of the folders.. Can't think of another decent method... Link to comment Share on other sites More sharing options...
FuryCell Posted May 30, 2005 Author Share Posted May 30, 2005 (edited) Also, how can the user tell apart a folder and a file ?One way of doing it is to add a "\" at the end of the folders..Can't think of another decent method... <{POST_SNAPBACK}>I don't understand do you mean for my script to add a "\"? If so i would need to know how to find the diffrenceEdit:Oops! Didn't see layers post. :"> I will try to update file list with the flags like you said using layers idea of filegetattrib Edited May 30, 2005 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
layer Posted May 30, 2005 Share Posted May 30, 2005 Oh yea! You don't need to use the MsgBox stuff too lol, that was just for testing! Use it and modify it as you'd like! FootbaG Link to comment Share on other sites More sharing options...
FuryCell Posted May 30, 2005 Author Share Posted May 30, 2005 (edited) Here is the new version.    I added the flag Parameters that Helge gave me the idea for to _FileList ().I also made _RegValueList() and _RegKeyList () into one function called _RegList() that uses flagsNow it contains two functions._FileList ():;=============================================================================== ; ; Description: Lists all files and folders in a specified path. (Similar to using Dir with the /B Switch) ; Syntax: _FileList($sPath,$iFlag=0) ; Parameter(s): $sPath = Path to generate filelist for ; $iFlag = determines weather to return file or folders or both ; $iFlag=0(Default) Return both files and folders ; $iFlag=1 Return files only ; $iFlag=2 Return Folders only ; ; Requirement(s): None ; Return Value(s): On Success - Returns an array containing the list of files and folders in the specified path ; On Failure - Returns an empty string "" if no files are found and sets @Error on errors ; @Error=1 Path Not Found ; @Error=2 Invalid $iFlag ; Author(s): SolidSnake <MetalGearX91@Hotmail.com> ; Note(s): The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of Files\Folders returned ; $array[1] = 1st File\Folder ; $array[2] = 2nd File\Folder ; $array[3] = 3rd File\Folder ; $array[n] = nth File\Folder ; ; Special Thanks to Helge,Layer and /dev/null for help with the $iFlag update ;===============================================================================and _RegList ():;=============================================================================== ; ; Description: lists all entries in a specified key ; Syntax: _RegList($sKey,$$iFlag=0) ; Parameter(s): $sKey = Key to generate keylist for ; $iFlag=0(Default) Return both keys and values ; $iFlag=1 Return values only ; $iFlag=2 Return keys only ; Requirement(s): None ; Return Value(s): On Success - Returns an array containing the list of entries in the specified key ; On Failure - Returns an empty string "" if no entries are found and sets @Error on errors ; @Error=1 $sKey not found ; @Error=2 Invalid $iFlag ; Author(s): SolidSnake <MetalGearX91@Hotmail.com> ; Note(s): The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of entries returned ; $array[1] = 1st entry ; $array[2] = 2nd entry ; $array[3] = 3rd entry ; $array[n] = nth entry ;===============================================================================Enjoy EDIT: Updated again. See post further below. Edited June 28, 2005 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
FuryCell Posted June 2, 2005 Author Share Posted June 2, 2005 (edited) Updated. Fixed a typo with the documentation for _RegList (). Edited June 2, 2005 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted June 2, 2005 Share Posted June 2, 2005 Wow, that's nice. Btw, the post above yours you have the _RegList() in the _FileList code box... I know the perfect script to use this too! Thanks! Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
FuryCell Posted June 4, 2005 Author Share Posted June 4, 2005 Wow, that's nice. Btw, the post above yours you have the _RegList() in the _FileList code box...I know the perfect script to use this too! Thanks!<{POST_SNAPBACK}>Thanks for the feedback. I fixed the post. HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
blindwig Posted June 4, 2005 Share Posted June 4, 2005 SolidSnake, (and anyone else interested)I wrote similiar routines because I got tired of having to re-write a search routine (using FileFindFirst and FileFindNext) everytime I need to scan for files. I needed a little more powerful filtering (I can filter not only based on file/folder, but on any attributes, like hidden, archive, compressed, etc)Have a look, I just posted them:http://www.autoitscript.com/forum/index.php?showtopic=12152 My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
FuryCell Posted June 28, 2005 Author Share Posted June 28, 2005 (edited) Updated. _FileList() now has wildcard ablilities.CODE;===============================================================================;; Description: lists all files and folders in a specified path (Similar to using Dir with the /B Switch); Syntax: _FileList($sPath, $sFilter = "*", $iFlag = 0); Parameter(s): $sPath = Path to generate filelist for; $iFlag = determines weather to return file or folders or both; $sFilter = The filter to use. Search the Autoit3 manual for the word "WildCards" For details; $iFlag=0(Default) Return both files and folders; $iFlag=1 Return files Only; $iFlag=2 Return Folders Only;; Requirement(s): None; Return Value(s): On Success - Returns an array containing the list of files and folders in the specified path; On Failure - Returns an empty string "" if no files are found and sets @Error on errors; @Error=1 Path not found or invalid; @Error=2 Invalid $sFilter; @Error=3 Invalid $iFlag;; Author(s): SolidSnake <MetalGearX91@Hotmail.com>; Note(s): The array returned is one-dimensional and is made up as follows:; $array[0] = Number of Files\Folders returned; $array[1] = 1st File\Folder; $array[2] = 2nd File\Folder; $array[3] = 3rd File\Folder; $array[n] = nth File\Folder;; Special Thanks to Helge and Layer for help with the $iFlag update;===============================================================================CODE;===============================================================================;; Description: lists all entries in a specified key; Syntax: _RegList($sKey,$$iFlag=0); Parameter(s): $sKey = Key to generate keylist for; $iFlag=0(Default) Return both keys and values; $iFlag=1 Return values Only; $iFlag=2 Return keys Only; Requirement(s): None; Return Value(s): On Success - Returns an array containing the list of entries in the specified path; On Failure - Returns an empty string "" if no entries are found and sets @Error on errors; @Error=1 $sKey not found; @Error=2 Invalid $iFlag; Author(s): SolidSnake <MetalGearX91@Hotmail.com>; Note(s): The array returned is one-dimensional and is made up as follows:; $array[0] = Number of entries returned; $array[1] = 1st entry; $array[2] = 2nd entry; $array[3] = 3rd entry; $array[n] = nth entry;===============================================================================Edit:Updated headers to reflect my new email address.(Previous Downloads 188) Edited December 11, 2006 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
HyperChao Posted July 23, 2005 Share Posted July 23, 2005 (edited) I've written a program very similar to this one, except mine also searches for files inside folders found in the original folder (and files in folders in those folders, etc ) until every single file contained in the specified folder is accounted for. If anyone is interested, I can post details. Perhaps SolidSnake can just implement it into his code, although two arrays are involved. I suppose the information can be condensed into one array, but then it gets messy... [EDIT] Okay, so condensing it into one array wasn't as messy as I thought... just complicated to explain. Here goes: $list[0][0] = number of folders and subfolders $list[0][x] = x-th folder (a folder's number has no significance as to its location) $list[x][0] = number of files in the folder $list[0][x] $list[x][$y] = y-th file in folder $list[0][x] The path stored in $list[0][x] is enough so that $dir & $list[0][x] will take you where you want. The code isn't documented well, but if anyone wants me to post it just ask. Edited July 23, 2005 by HyperChao Link to comment Share on other sites More sharing options...
Wus Posted July 23, 2005 Share Posted July 23, 2005 cant hurt to post it... so you might as well... 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