Jump to content

Using FileCopy in array?


4Bravo
 Share

Recommended Posts

I've double checked the arrays, and used the function manually, with out the array. But I don't know where to plug this FileCopy in a For and Next. Every time I execute it I get an oddly named file in the directory the script was launched from.

Blah... I realised I forgot [$i] after the array

#include <Array.au3>
#include <RecFileListToArray.au3>
AutoItSetOption("TrayIconDebug",True)
$sPath = "D:Temp"
$movFILE = "D:mov.veg"
$flaDIR = _RecFileListToArray($sPath, "*.fla", 1, 1, 0, 2)
$justFILE = _RecFileListToArray($sPath, "*.fla", 1, 1, 0, 0)

For $i = 1 To $justFILE[0]
$justFILE[$i] = StringTrimRight($justFILE[$i], 4)
next
For $i = 1 To $flaDIR[0]
$flaDIR[$i] = StringReplace($flaDIR[$i], $justFILE[$i] & ".fla", "")

FileCopy($movFILE, $flaDIR[$i])
next
Edited by 4Bravo
Link to comment
Share on other sites

It appears as though you are searching for each directory that contains an "fla" file and copying "mov.reg" to that directory. You can try this as it is little less code:

#include <Array.au3>
#include <RecFileListToArray.au3>
AutoItSetOption("TrayIconDebug", True)
Local $sPath, $movFILE, $DestDir
$sPath = "D:Temp"
$movFILE = "D:mov.veg"
$flaDIR = _RecFileListToArray($sPath, "*.fla", 1, 1, 0, 2)

For $i = 1 To $flaDIR[0]
$DestDir = StringRegExpReplace($flaDIR[$i], '[^]+$', '')
FileCopy($movFILE, $DestDir)
Next
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...