Jump to content

Dir Contents


Recommended Posts

How can I select C:\ and return two arrays

$dirs[0] containing # of entries

$dirs[1-n] containing dir names

$files[0] containing # of entires

$files[1-n] containing file names

I'm trying to build a script that generates a file listing a systems contents in a tree format. If its been done please direct :)

I AM ORCA!! A VERY POWERFUL WHALE!!!

Link to comment
Share on other sites

CMD is dissabled on the computer I'm interested in running this. The reason for the script is that I'm disallowed from the C:[local] as a user, but autoit can access it just fine. Since I can't normally walk in and view contents I need something that can do it for me.

I AM ORCA!! A VERY POWERFUL WHALE!!!

Link to comment
Share on other sites

1) Have you seen the DirGetSize function (notice the flag 1 option)

2) There is also the DOS "tree" command...

Run(@ComSpec & " /c tree C: /F") ;visually verify the command works

Run(@ComSpec & " /c tree C: /F > C:\OutputOfTree.txt") ;redirect to file

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

How can I select C:\ and return two arrays

$dirs[0] containing # of entries

$dirs[1-n] containing dir names

$files[0] containing # of entires

$files[1-n] containing file names

I'm trying to build a script that generates a file listing a systems contents in a tree format. If its been done please direct :)

<{POST_SNAPBACK}>

I'll leave filling the arrays to you, but here is a sample calling out to the FileSystemObject using the ObjCreate function in the new release available from the Developer forum:

$fso = ObjCreate("Scripting.FileSystemObject");Instantiate FileSystemObject
$rootFolder = "C:\"
$root = $fso.GetFolder($rootFolder) 
$subs = $root.SubFolders; Create SubFolders Collection
ConsoleWrite("There are " & $subs.count & " folders in " & $rootFolder & @CR)
For $fol in $subs; Loop through each subfolder in folder collection
    ConsoleWrite(@TAB & $fol.name & " has " & $fol.files.count & " files" & @CR)
    If $fol.name = "System Volume Information" then ContinueLoop; Special folder, skip
    $files = $fol.Files; Create files collection in subfolders
    For $file in $files; Loop through files in folders
        ConsoleWrite(@TAB & @TAB & $file.name & " (" & $file.size & " bytes)" & @CR)
    Next
Next

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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...