Sign in to follow this  
Followers 0
myspacee

FileFindFirstFile()

9 posts in this topic

hello,

use FileFindFirstFile to return list of directories on given path.

all works fine, util directories names are in this format :

SS.F70824

SS.F70825

SS.F70826

SS.F70827

SS.F70828

SS.F70829

..

Dot (SS.) in directories name, brokes all script engine, and can't resolve.

Is there a way to list all directory also in this format ?

(can't touch them, as part of production cicle)

Thank you,

m.

Share this post


Link to post
Share on other sites



hello,

use FileFindFirstFile to return list of directories on given path.

all works fine, util directories names are in this format :

SS.F70824

SS.F70825

SS.F70826

SS.F70827

SS.F70828

SS.F70829

..

Dot (SS.) in directories name, brokes all script engine, and can't resolve.

Is there a way to list all directory also in this format ?

(can't touch them, as part of production cicle)

Thank you,

m.

I tested the following and it works for me - c:\ mb contains directories you named above

[/code]
; Shows the filenames of all files in the current directory.#'
#include <array.au3>
; Shows the filenames of all files in the current directory.#'
#include <array.au3>

Dim $DirListing[1]

$search = FileFindFirstFile("C:\mb\*.*") 
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    
    _ArrayAdd($DirListing, $file)
    
WEnd

; Close the search handle
FileClose($search)
_ArrayDisplay($DirListing)

[code]

Share this post


Link to post
Share on other sites

myspacee

Can you make a small example to duplicate this problem?

Share this post


Link to post
Share on other sites

my for example:

in c:\mb\ i've these folders and some files...

SS.F70824

SS.F70825

SS.F70826

SS.F70827

SS.F70828

SS.F70829

goofy.pdf

goofy.ini

donald.pdf

donald.ini

need to list only directories (need directory name for script), but SS. give me some problem (not recognized as directory)

bourny thank you for script but array contains also filenames, i need only directories name.

thank you both,

m.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

my for example:

in c:\mb\ i've these folders and some files...

need to list only directories (need directory name for script), but SS. give me some problem (not recognized as directory)

bourny thank you for script but array contains also filenames, i need only directories name.

thank you both,

m.

Use _FileListToArray($sPath,"*",2). Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites

Try this:

#include <array.au3>

Dim $DirListing[1]

$search = FileFindFirstFile("C:\mb\*")
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    
    If StringInStr(FileGetAttrib("C:\mb\" & $file), "D") <> 0 Then _ArrayAdd($DirListing, $file)
    
WEnd

; Close the search handle
FileClose($search)
_ArrayDisplay($DirListing)

Share this post


Link to post
Share on other sites

zorphnog, tricky but perfect. :)

m.

Share this post


Link to post
Share on other sites

sorry to retake this post.

Working again with FileFindFirstFile() and directory

i've this structure :

c:\A\
c:\A\1\lion.txt
c:\A\1\cat.txt
c:\A\1\dog.txt
c:\A\2\lemon.txt
c:\A\2\banana.txt
c:\A\3\autoit.txt

try to write script that scan sub-directory and return files one by one with no luck.

Anyone can help ?

m.

Share this post


Link to post
Share on other sites

myspacee,

Here is a recursive search script which will get all files in a tree of folders. All you need to do is substitute the start (top level) folder and the filename (*.* for everything).

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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