n9mfk9 Posted August 28, 2007 Share Posted August 28, 2007 Hi all I am have trouble with Filecopy no matter what i do i get 0 instead of 1 expandcollapse popup#Include <File.au3> #Include <Array.au3> $FileOut= 'C:\new\error.txt' $originalDir = 'C:\wdisplay' $destinationDir= 'C:\new\wd7\' $hFileOut = FileOpen($FileOut, 2) DirCreate($destinationDir) $status='' $FileList=_FileListToArray($originalDir,"**",1) $FolderList=_FileListToArray($originalDir, '**', 2) If @Error=1 Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf ;_ArrayDisplay($FileList,"$FileList") ;_ArrayDisplay($FolderList,'$FolderList') For $n= 1 to $FileList[0] $Filetest= FileCopy($originalDir,$destinationDir,8) Select Case $Filetest = 1 $Filetest = "OK" case $Filetest = 0 $Filetest = "error" EndSelect $text1= $originalDir&$FileList[$n]&' -> ' &$destinationDir&$FileList[$n] &' '& $Filetest&@CRLF FileWrite($hFileOut, $text1) ;MsgBox(0,"", $text1) Next For $n= 1 to $FolderList[0] $DirTest = DirCopy($originalDir,$destinationDir,1) Select Case $DirTest = 1 $DirTest = "OK" case $DirTest =0 $DirTest = "error" EndSelect $text2= $originalDir&$FolderList[$n]&' -> ' &$destinationDir&$FolderList[$n] &' '& $DirTest&@CRLF FileWrite($hFileOut, $text2) ;MsgBox(0,"", $text2) Next FileClose($hFileOut) thanks for any help Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 28, 2007 Moderators Share Posted August 28, 2007 (edited) Going to have a hell of a time if the file stays open to copy it somewhere ... expandcollapse popup#Include <File.au3> #Include <Array.au3> $FileOut = 'C:\new\error.txt' $originalDir = 'C:\wdisplay' $destinationDir = 'C:\new\wd7\' FileClose(FileOpen($FileOut, 2)) DirCreate($destinationDir) $status = '' $FileList = _FileListToArray($originalDir, "**", 1) $FolderList = _FileListToArray($originalDir, '**', 2) If @error = 1 Then MsgBox(0, "", "No Files\Folders Found.") Exit EndIf ;_ArrayDisplay($FileList,"$FileList") ;_ArrayDisplay($FolderList,'$FolderList') For $n = 1 To $FileList[0] $Filetest = FileCopy($originalDir, $destinationDir, 8) Select Case $Filetest = 1 $Filetest = "OK" Case $Filetest = 0 $Filetest = "error" EndSelect $text1 = $originalDir & $FileList[$n] & ' -> ' & $destinationDir & $FileList[$n] & ' ' & $Filetest & @CRLF FileWrite($FileOut, $text1) ;MsgBox(0,"", $text1) Next For $n = 1 To $FolderList[0] $DirTest = DirCopy($originalDir, $destinationDir, 1) Select Case $DirTest = 1 $DirTest = "OK" Case $DirTest = 0 $DirTest = "error" EndSelect $text2 = $originalDir & $FolderList[$n] & ' -> ' & $destinationDir & $FolderList[$n] & ' ' & $DirTest & @CRLF FileWrite($FileOut, $text2) ;MsgBox(0,"", $text2) Next Edited August 28, 2007 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. Link to comment Share on other sites More sharing options...
n9mfk9 Posted August 28, 2007 Author Share Posted August 28, 2007 Hi Smoke_n, I have a question why do fileClose(FileOpen($FileOut, 2)) at the top why not do a file close at the end? thanks Going to have a hell of a time if the file stays open to copy it somewhere ... expandcollapse popup#Include <File.au3> #Include <Array.au3> $FileOut = 'C:\new\error.txt' $originalDir = 'C:\wdisplay' $destinationDir = 'C:\new\wd7\' FileClose(FileOpen($FileOut, 2)) DirCreate($destinationDir) $status = '' $FileList = _FileListToArray($originalDir, "**", 1) $FolderList = _FileListToArray($originalDir, '**', 2) If @error = 1 Then MsgBox(0, "", "No Files\Folders Found.") Exit EndIf ;_ArrayDisplay($FileList,"$FileList") ;_ArrayDisplay($FolderList,'$FolderList') For $n = 1 To $FileList[0] $Filetest = FileCopy($originalDir, $destinationDir, 8) Select Case $Filetest = 1 $Filetest = "OK" Case $Filetest = 0 $Filetest = "error" EndSelect $text1 = $originalDir & $FileList[$n] & ' -> ' & $destinationDir & $FileList[$n] & ' ' & $Filetest & @CRLF FileWrite($FileOut, $text1) ;MsgBox(0,"", $text1) Next For $n = 1 To $FolderList[0] $DirTest = DirCopy($originalDir, $destinationDir, 1) Select Case $DirTest = 1 $DirTest = "OK" Case $DirTest = 0 $DirTest = "error" EndSelect $text2 = $originalDir & $FolderList[$n] & ' -> ' & $destinationDir & $FolderList[$n] & ' ' & $DirTest & @CRLF FileWrite($FileOut, $text2) ;MsgBox(0,"", $text2) Next Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now