Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

How can get all files of a directory and the subdirectory?


  • Please log in to reply
9 replies to this topic

#1 FlyInSky

FlyInSky

    Seeker

  • Active Members
  • 11 posts

Posted 27 October 2006 - 05:54 PM

This is my code.Why it's only get the first every subdirectory?
Plain Text         
Global $List[1]=[0] Func FileListToArray($Dir)     Dim $FilePath,$FilesList,$Files,$i     $FilesList=_FileListToArray($Dir)     If (Not IsArray($FilesList)) and (@Error=1) Then         MsgBox (0,"","No Files\Folders Found.")         Return     EndIf     $Files=_FileListToArray($Dir,"*",1)     If IsArray($Files) Then         For $i=1 To $Files[0]             $FilePath=$Dir&"\"&$Files[$i]             ReDim $List[UBound($List)+1]             $List[0]=$List[0]+1             $List[UBound($List)-1]=$FilePath         Next     EndIf     $SubDir=_FileListToArray($Dir,"*",2)     If IsArray($SubDir) Then         For $i=1 To $SubDir[0]             $FullPath=$Dir&"\"&$SubDir[$i]             $tempList=FileListToArray($FullPath)             For $i=1 To $tempList[0]                 ReDim $List[UBound($List)+1]                 $List[0]=$List[0]+1                 $List[UBound($List)-1]=$tempList[$i]             Next            Next     EndIf     Return $List EndFunc

Edited by FlyInSky, 27 October 2006 - 05:56 PM.








#2 GaryFrost

GaryFrost

    I don't need your attitude. I have one of my own

  • Developers
  • 7,854 posts

Posted 27 October 2006 - 05:55 PM

This is Scripts and Scraps not Support

SciTE for AutoItDirections for Submitting Standard UDFs

Don't argue with an idiot; people watching may not be able to tell the difference.


#3 FlyInSky

FlyInSky

    Seeker

  • Active Members
  • 11 posts

Posted 27 October 2006 - 05:59 PM

What is another way to do it?

#4 Valuater

Valuater

    www.PayFreeWireless.com

  • MVPs
  • 11,200 posts

Posted 27 October 2006 - 06:43 PM

might want to take a look at this FileListToArray() by SmOke_N

http://www.autoitscript.com/forum/index.ph...st&p=246376

8)

Edited by Valuater, 27 October 2006 - 06:43 PM.

Posted Image

Clic The Pic!!!


#5 FlyInSky

FlyInSky

    Seeker

  • Active Members
  • 11 posts

Posted 27 October 2006 - 06:56 PM

might want to take a look at this FileListToArray() by SmOke_N

http://www.autoitscript.com/forum/index.ph...st&p=246376

8)

Thank you :whistle:
But it's not i need.I need a function of all subdirectoryies files.

Edited by FlyInSky, 27 October 2006 - 07:13 PM.


#6 FlyInSky

FlyInSky

    Seeker

  • Active Members
  • 11 posts

Posted 27 October 2006 - 07:30 PM

I have another script about it,it's work,why my script don't work?
Func _filelist($searchdir)        $search = FileFindFirstFile($searchdir & "\*.*")        If $search = -1 Then return -1              While 1     $file = FileFindNextFile($search)                   If @error Then                    FileClose($search)                  return                                       Elseif  $file = "."  or $file = ".." Then          ContinueLoop                                               ElseIf stringinstr(FileGetAttrib($searchdir & "\" & $file),"D") then         _filelist($searchdir & "\" & $file)             EndIf                               ConsoleWrite( $searchdir & "\" & $file & @crlf ) WEnd EndFunc


#7 dabus

dabus

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 405 posts

Posted 27 October 2006 - 10:21 PM

Try this one: http://www.autoitscript.com/forum/index.php?showtopic=5458
Or even faster (at least for me): use dir and parse
... oh, sorry, did you want to use FileListToArray by all means?!?

#8 FlyInSky

FlyInSky

    Seeker

  • Active Members
  • 11 posts

Posted 28 October 2006 - 12:47 AM

Try this one: http://www.autoitscript.com/forum/index.php?showtopic=5458
Or even faster (at least for me): use dir and parse
... oh, sorry, did you want to use FileListToArray by all means?!?

Yes.I want to get all files in the directory .

#9 suppa2

suppa2

    Seeker

  • Active Members
  • 14 posts

Posted 03 January 2007 - 07:05 PM

I'm very new to Autoit3. Well, I needed such a function, too,so I made one which works :P

Func _getdirandsubdirs($dir) $c=1; $d=0; $temp=""; $folders=_FileListToArray($dir,"*.",2) While $c < UBound($folders, 1)     $temp=_FileListToArray($musicfolder&$folders[$c],"*.",2)         $d=1;     While $d < UBound($temp, 1)         _ArrayAdd($folders,$folders[$c]&"/"&$temp[$d])         $d=$d+1;     WEnd     $c=$c+1; WEnd _ArrayDelete($folders, 0) _ArraySort($folders); return $folders; EndFunc

Edited by suppa2, 03 January 2007 - 07:07 PM.

Posted Image Posted Image

#10 yidabu

yidabu

    Seeker

  • Active Members
  • 10 posts

Posted 25 January 2007 - 07:22 AM

I write a autoit udf to suport subdirectory and suport RegExp, see:
http://www.autoitscript.com/forum/index.php?showtopic=40063
my UDF:myReplaceStringInFile suport StringRegExp and subdirectorymyFileListToArray suport StringRegExp and subdirectorymyImageIdentify get all information from image, use Image Magick com supportautoit in Chinaautoit 论坛yidabu成功社区




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users