Jump to content

Array File Copy


Recommended Posts

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.
Link to comment
Share on other sites

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:\.

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...