Jump to content
Sign in to follow this  
EndFunc

Array File Copy

Recommended Posts

EndFunc

For some reason I can't get this to copy. It displays what it should look like in a message box as far as the path but just won't copy files. The files types are being read from an ini file into an array with StringSplit but can't it to copy any type matching that to the specified directory.

$SFDestination = IniRead($ConfigFile, "ConfigSet", "SFLocation", "NotFound")
$SearchType = IniRead($ConfigFile, "ConfigSet", "Search", "NotFound")
$SearchFile = StringSplit($SearchType, "|")
$sCheckPath = FileGetAttrib($SFDestination)
If Not StringInStr($sCheckPath, "D") Then 
DirCreate($SFDestination)
EndIf
GUICtrlSetData($Console, "Scanning for specific file types." & @CRLF, 1)
For $c = 1 To $SearchFile[0]
GUICtrlSetData($Console, "Transferring " & $SearchFile[$c] & " files, please hold." & @CRLF & @CRLF, 1)
FileCopy("C:\*" & $SearchFile[$c], $SFDestination, 9)
Next

Thanks

Edit: yes I know the Dircreate part is kinda redundant when using the Filecopy 9 flag.

Edited by EndFunc

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites
MHz

May work better with a backslash.

FileCopy("C:\*" & $SearchFile[$c], $SFDestination & '\', 9)

The 9 flag has the effect of wanting a backslash to work ok.

:)

Share this post


Link to post
Share on other sites
EndFunc

It still doesn't like that. It just zooms by. I even tried doing this.

FileCopy("C:\*" & $SearchFile[$c], $SFDestination & "\*.*", 9)

And still doesn't work. Hmm??


EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites
MHz

It may depend what is in your ini file perhaps. Test works ok for me with the below.

FileChangeDir('c:\')
$ConfigFile = 'config.ini'

$SFDestination = IniRead($ConfigFile, "ConfigSet", "SFLocation", "NotFound")
$SearchType = IniRead($ConfigFile, "ConfigSet", "Search", "NotFound")
$SearchFile = StringSplit($SearchType, "|")
$sCheckPath = FileGetAttrib($SFDestination)
If Not StringInStr($sCheckPath, "D") Then
    DirCreate($SFDestination)
EndIf
;~ GUICtrlSetData($Console, "Scanning for specific file types." & @CRLF, 1)
For $c = 1 To $SearchFile[0]
;~  GUICtrlSetData($Console, "Transferring " & $SearchFile[$c] & " files, please hold." & @CRLF & @CRLF, 1)
    FileCopy("C:\*" & $SearchFile[$c], $SFDestination, 9)
Next

Ini file used.

[ConfigSet]
SFLocation=folder
Search=.txt

And I finished with "folder" with a txt file inside from c:\.

Share this post


Link to post
Share on other sites
EndFunc

that's weird because I still can't get it to work. It just zips right by. is there a better way to do this maybe?


EndFuncAutoIt is the shiznit. I love it.

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  

×