Jump to content
Sign in to follow this  
Ices

Need some help, Yet Again

Recommended Posts

Ices

I want my script to open a command prompt, do a directory list, then make a text file, and copying the directory list to the text file.

Opening the command prompt and making the text file I got, but how would I get the directory list from the command prompt to the text file? Any ideas?

Also, if I can get a directory list without the use of a command line, I could do that instead, Im open to suggestions

Edited by Ices

Share this post


Link to post
Share on other sites
ezzetabi

May help...

$sDirectory = 'c:\';Put the directory name here
$sOutPutFile = 'd:\test.txt';Put the output file name here


If StringRight($sDirectory,1) <> '\' Then $sDirectory = $sDirectory & '\'
$iHandle = FileFindFirstFile($sDirectory & '*.*')

While $iHandle <> -1
   $sFileName = FileFindNextFile($iHandle)
   If @error Then
      FileClose($iHandle)
      ExitLoop
   EndIf
   
   $sList = $sList & @CRLF & $sDirectory & $sFileName 
WEnd

$sList = StringTrimLeft($sList,2);Remove the heading @crlf

FileDelete($sOutPutFile)
FileWrite($sOutPutFile,$sList)
Edited by ezzetabi

Share this post


Link to post
Share on other sites
buzz44

use this to run a hidden cmd window and get dir

#include <Process.au3>

_RunDos("Dir" & " > " & @TempDir & "\temp.txt")

Change @TempDir & "\temp.txt", to the place you want to same the text file as, and also change "dir" by first opening the directory to get files/fodler of


qq

Share this post


Link to post
Share on other sites
Ices

Thanks Much ezzetabi, it worked great. Im almost done with my program :idiot:

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.