Jump to content
Sign in to follow this  
PcExpert

Can autoit "see" directories

Recommended Posts

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

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



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

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

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.

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")

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.

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

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  

×
×
  • Create New...