Vadersapien Posted October 30, 2009 Posted October 30, 2009 How can I List the Contents of a Directory? I need be able to list both files AND folders within the directory. I've had a look around the forums, but nothing seems to suit my needs. Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
omikron48 Posted October 30, 2009 Posted October 30, 2009 You use FileFindFirstFile to get the first file/folder in a directory, then use FileFindNextFile to iterate through all the contents of the directory until you hit an error indicating that there are no more items.
Achilles Posted October 30, 2009 Posted October 30, 2009 Or use the function _FileListtoArray Example (from the helpfile): #Include <File.au3> #Include <Array.au3> $FileList=_FileListToArray(@DesktopDir) If @Error=1 Then MsgBox (0,"","No Folders Found.") Exit EndIf If @Error=4 Then MsgBox (0,"","No Files Found.") Exit EndIf _ArrayDisplay($FileList,"$FileList") My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Vadersapien Posted October 31, 2009 Author Posted October 31, 2009 Thanks, both methods work well, although I prefer the first method since it allows me to do whatever I want with the result, instead of just pushing it to an array... Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Vadersapien Posted November 4, 2009 Author Posted November 4, 2009 How would I detect what is a folder and what is a file? Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
99ojo Posted November 4, 2009 Posted November 4, 2009 How would I detect what is a folder and what is a file?Hi,I would prefer _FileListToArray, because you can choose listing files / folders and you have an array to work with. Otherwise you have to check with FileGetAttrib () -> see helpfileHelpfile:_FileListToArray --------------------------------------------------------------------------------Lists files and\or folders in a specified path (Similar to using Dir with the /B Switch);-))Stefan
Vadersapien Posted November 4, 2009 Author Posted November 4, 2009 An array would be useless in the way I'm using it...and thanks for telling me about FileGetAttrib ()! Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
Vadersapien Posted November 5, 2009 Author Posted November 5, 2009 But how would I dectect the type properly if FileGetAttrib() returns a string like HD(Hidden + Directory)? Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.
omikron48 Posted November 5, 2009 Posted November 5, 2009 Use StringInStr on the output of the FileGetAttrib.
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