Sign in to follow this  
Followers 0
kkman360

Help ! It's Worng?

8 posts in this topic

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)

Share this post


Link to post
Share on other sites



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.


[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

1

try this

MsgBox(0,"d:\test\dc\*.*","d:\test\" & $file & "\*")
;FileCopy("d:\test\dc\*.*","d:\test\" & $file & "\*" ,1)

2

dont you want to copy from $file... to the new location??

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

and $search is name of folder?

thanks.

Edited by kkman360

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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)


[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

#7 ·  Posted (edited)

yes! you are right.

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

thanks evry much.

Edited by kkman360

Share this post


Link to post
Share on other sites

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.


[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

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