Jump to content

Write directory to a text file.


Pottery
 Share

Recommended Posts

Hey, I made this for a family member because he has a list of movies and wanted to make a text file contraining all of the movie names so I thought I'd share this; it could be useful I suppose :D

Bath version:

$path = IniRead("settings.ini", "path", "folder path", "default")

If $Path = "default" Then
    MsgBox(64, "Error", "Error - setup your folder path in settings.ini!")
    ShellExecute("settings.ini", "", "", "edit")
    Exit
EndIf

Run("cmd.exe")
Sleep(200)
Send("cd " & $path & "{enter}")
Sleep(100)
Send("dir > list.txt" & "{enter}")
Sleep(100)
ProcessClose("cmd.exe")
Sleep(200)
ShellExecute("list.txt", "", $path, "edit")

AutoIt3 functions version:

#include <File.au3>

$myList = _FileListToArray(@MyDocumentsDir)
_FileCreate(@DesktopDir & "\List.txt")
_FileWriteFromArray(@DesktopDir & "\List.txt", $myList)

It's not much, but I find it useful. Thanks, Exhalt.

*EDIT*

Added AutoIt3 function version.

DirectoryToText.rar

Edited by Exhalt
Link to comment
Share on other sites

As I said, I would post this today. I made it quick without thinking about it for someone; here's the script.

#include <File.au3>

$myList = _FileListToArray(@MyDocumentsDir)
_FileCreate(@DesktopDir & "\List.txt")
_FileWriteFromArray(@DesktopDir & "\List.txt", $myList)

Uhh...what?

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

  • 13 years later...

Good day,

Maybe...a bit of an update...I simply required the ability to enter the specified data path...

;-----------------------------------------------
#include <File.au3>
; -----------------------------------------------
GetDatapath()
;-----------------------------------------------
Func GetDatapath()
    ; Declare the variables
    Local $MyPath = ''
    Local $MyList = ''
    ;----------------
    ; Obtain path from user input
    $MyPath = InputBox("NOTICE!", "Enter the complete file path...", "", "", 150, 50)
    ;-----------------------------------------------
    ; Assign $MyPath to $MyList and create the array
    $MyList = _FileListToArray($MyPath)
    ; Create the data file
    _FileCreate($MyPath & "\FileListing.txt")
    ; Write the array to the data file
    _FileWriteFromArray($MyPath & "\FileListing.txt", $MyList)
EndFunc   ;==>GetDatapath
;-----------------------------------------------

Thanks for this, Pottery...very much appreciated!

Edited by mr-es335
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...