Sign in to follow this  
Followers 0
PcExpert

Can autoit "see" directories

13 posts in this topic

Hi,

It possible to let AutoIt search for directories inside another directory? For exaple:

You want to know the directory name from a directory that's in another directory. Can AutoIt do that?

Thanks!

Share this post


Link to post
Share on other sites



Hi,

It possible to let AutoIt search for directories inside another directory? For exaple:

You want to know the directory name from a directory that's in another directory. Can AutoIt do that?

Thanks!

FileFindFirstFile() and FileFindNextFile(). See help file sample.

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I'm new here...I cant help...but learn from your post...

Wish you to find the answer as soon as possible! ha!

Edited by yangmo

地球人都知道走人要厚道!---Human being all know that it is important to be a generous man...

Share this post


Link to post
Share on other sites

But what kind of extention do I have to put in to search for the names of the direcories then?

Share this post


Link to post
Share on other sites

If you do not want a recurrsive search then lookup _FileListToArray in the help file and look at the flags.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Just put the directory you want to search...

Func _DirRecurse($hDirectory)
    RunWait(@Comspec & ' /c dir /b /s /a "' & $hDirectory & '" > "' & _
        @TempDir & '\RecursivOutput.txt"', @WorkingDir, @SW_HIDE)
    If Not FileExists(@TempDir & '\RecursivOutput.txt') Then Return SetError(1, 0, 0)
    Local $sFRead = FileRead(@TempDir & '\RecursivOutput.txt')
    FileDelete(@TempDir & '\RecursivOutput.txt')
    Return $sFRead
EndFunc

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

OK, I'll explain what I want to do:

I want to search for other user accounts, now I only know howto check the logged in user , but I want to check if there are more profiles. Is that possible?

Share this post


Link to post
Share on other sites

OK, I'll explain what I want to do:

I want to search for other user accounts, now I only know howto check the logged in user , but I want to check if there are more profiles. Is that possible?

#include <file.au3>
#include <array.au3>
$profile_path = EnvGet("USERPROFILE")
Dim $szDrive, $szDir, $szFile, $stExt

$retarray = _PathSplit($profile_path,$szDrive,$szDir,$szFile,$stExt)

$profile_dir = $szDrive & $szDir
$profile_list = _FileToArray($profile_dir)
_ArrayDisplay($profile_list,"All User Profiles")

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

#include <file.au3>
#include <array.au3>
$profile_path = EnvGet("USERPROFILE")
Dim $szDrive, $szDir, $szFile, $stExt

$retarray = _PathSplit($profile_path,$szDrive,$szDir,$szFile,$stExt)

$profile_dir = $szDrive & $szDir
$profile_list = _FileToArray($profile_dir)
_ArrayDisplay($profile_list,"All User Profiles")

Cheers

Kurt

That's not a working example Kurt... I can see you did a me and probably typed in the fast reply window :)

Did you mean something like?

#include <file.au3>
#include <array.au3>
$profile_path = EnvGet("USERPROFILE")
Dim $szDrive, $szDir, $szFile, $stExt

$retarray = _PathSplit($profile_path,$szDrive,$szDir,$szFile,$stExt)

$profile_dir = $szDrive & $szDir
$profileList = _FileListToArray($profile_dir)
_ArrayDisplay($profileList,"All User Profiles")

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

That's not a working example Kurt... I can see you did a me and probably typed in the fast reply window :)

Did you mean something like?[autoit]#include <file.au3>

Yep, you're right. _FileToArray should read _FileListToArray. Thanks.

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

OK, I'll explain what I want to do:

I want to search for other user accounts, now I only know howto check the logged in user , but I want to check if there are more profiles. Is that possible?

#include <file.au3>
#include <array.au3>
$profile_path = @HomeDrive & @HomePath
ConsoleWrite($profile_path & @CRLF)
Dim $szDrive, $szDir, $szFile, $stExt

$retarray = _PathSplit($profile_path,$szDrive,$szDir,$szFile,$stExt)

$profile_dir = $szDrive & $szDir
$profileList = _FileListToArray($profile_dir)
_ArrayDisplay($profileList,"All Profile Folders")

Just a mod to some previous copied code to get all profile folders in "HomePath". :)

Share this post


Link to post
Share on other sites

Just a mod to some previous copied code to get all profile folders in "HomePath". :)

Even shorter with @UserProfileDir

#include <file.au3>
#include <array.au3>
Dim $szDrive, $szDir, $szFile, $stExt

$retarray = _PathSplit(@UserPofileDir,$szDrive,$szDir,$szFile,$stExt)

$all_profiles_dir = $szDrive & $szDir
$profile_list = _FileListToArray($all_profiles_dir)
_ArrayDisplay($profile_list,"All Profile Folders")

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Thanks all!

Edited by PcExpert

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  
Followers 0