Jump to content

Help ! It's Worng?


Recommended Posts

it does not work!why?

code:

$search = FileFindFirstFile("d:\test\*.*")

If $search = -1 Then

MsgBox(0, "Error", "No files/directories matched the search pattern")

Exit

EndIf

While 1

$file = FileFindNextFile($search)

If @error then

MsgBox(0, "ok", "copy complete")

ExitLoop

endif

FileCopy("d:\test\dc\*.*","d:\test\" & $search & "\*" ,1)

WEnd

; Close the search handle

FileClose($search)

Link to comment
Share on other sites

  • Moderators

Wow, I can't make heads or tails of what your doing... Can you just say what you want... from what I see, the $search in file copy is wrong, but I don't know why you are doing the filefindnext, if your just copying the entire folder, and then I don't know why you have "\*" as your extension in file copy.

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.

Link to comment
Share on other sites

i have 1290 folders in d:\test and copy d:\test\dc\*.* to each one.

thanks.

might want to look into FileListToArray()

to use folders/ and or files

#Include <File.au3>
#Include <Array.au3>
$FileList=_FileListToArray("d:\test\")
If (Not IsArray($FileList)) and (@Error=1) Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
_ArrayDisplay($FileList,"$FileList")

** not tested

Optional: specifies wheather to return files folders or both

$iFlag=0(Default) Return both files and folders

$iFlag=1 Return files only

$iFlag=2 Return Folders only

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

Without testing it, I would imagine it might look like this:

$search = FileFindFirstFile("*.*")  

If $search = -1 Then Exit

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    If StringInStr(FileGetAttrib($file), 'd') Then FileCopy("d:\test\dc\*.*", "d:\test\" & $file & '\', 1)
WEnd

FileClose($search)

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.

Link to comment
Share on other sites

  • Moderators

yes! you are right.

ha ha . i get a mistake .must use $file not $search .

thanks evry much.

you get "your" mistake?

Also.. to make sure your not trying to copy to a non-folder, you might try the Filegetattribute() option I put up there.

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...