Jump to content

How can I List the Contents of a Directory?


Recommended Posts

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.
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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 helpfile

Helpfile:

_FileListToArray

--------------------------------------------------------------------------------

Lists files and\or folders in a specified path (Similar to using Dir with the /B Switch)

;-))

Stefan

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...