Jump to content

Recommended Posts

Posted

What I have to accomplish is to move files in folderA to folderB on the same file system. Files could be coming into folderA from another process running so I want to make sure that I'm not trying to move a file being written to.

What I tried was use _FileListToArray to create an array of files. It works in creating the list but I also tested allowing the script to sleep for a minute while I copied a file into that folder. What I wanted was the list to copy the files into folderB without the new file I copied into folderA. But the end result was everything was copied.

Is _FileListToArray not able to create a static list?

Thanks for any help.

#Include <File.au3>

#Include <Array.au3>

$sFilter = "*"

$iFlag = "1"

$FileList=_FileListToArray("c:\temp\",$sFilter ,$iFlag)

If @Error=1 Then

MsgBox (0,"","0 Files found.")

Exit

EndIf

Sleep(60000)

FileCopy ( "c:\temp\" & $FileList, "c:\test\" & $FileList)

Posted

Hi,

if you do not update the array created by _FileListToArray then it should be "static"

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Posted

FileCopy ( "c:\temp\" & $FileList, "c:\test\" & $FileList)

Am I seeing this wrong or are you trying to copy a file named the entire content of the array??

Instead of that sentence try this untested bit:

For $i = 1 To $FileList[0]
       FileCopy ( "c:\temp\" & $FileList[$i], "c:\test\" & $FileList[$i])
Next

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Posted

What I have to accomplish is to move files in folderA to folderB on the same file system. Files could be coming into folderA from another process running so I want to make sure that I'm not trying to move a file being written to.

What I tried was use _FileListToArray to create an array of files. It works in creating the list but I also tested allowing the script to sleep for a minute while I copied a file into that folder. What I wanted was the list to copy the files into folderB without the new file I copied into folderA. But the end result was everything was copied.

Is _FileListToArray not able to create a static list?

Thanks for any help.

#Include <File.au3>
#Include <Array.au3>
$sFilter = "*"
$iFlag = "1"

$FileList=_FileListToArray("c:\temp\",$sFilter ,$iFlag)
If @Error=1 Then
    MsgBox (0,"","0 Files found.")
    Exit
EndIf
Sleep(60000)
FileCopy ( "c:\temp\" & $FileList, "c:\test\" & $FileList)
The way you're doing your FileCopy(), it's not referencing the array at all. $FileList is an array, not a single item. The way you're referencing it, $FileList is returning nothing, so your file copy paths are being interpreted as:

  • copy "C:\Temp\" to "C:\Test\"
Use a For...Next loop to process each item in the array individually, and you should be set:

#include <File.au3>
#include <Array.au3>
$sFilter = "*"
$iFlag = "1"

$FileList = _FileListToArray("c:\temp\", $sFilter, $iFlag)
If @error = 1 Then
    MsgBox(0, "", "0 Files found.")
    Exit
EndIf
Sleep(60000)
For $i = 1 To $FileList[0]
    FileCopy("c:\temp\" & $FileList[$i], "c:\test\" & $FileList[$i])
Next

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Posted (edited)

The way you're doing your FileCopy(), it's not referencing the array at all. $FileList is an array, not a single item. The way you're referencing it, $FileList is returning nothing, so your file copy paths are being interpreted as:

  • copy "C:\Temp\" to "C:\Test\"
Use a For...Next loop to process each item in the array individually, and you should be set:

#include <File.au3>
#include <Array.au3>
$sFilter = "*"
$iFlag = "1"

$FileList = _FileListToArray("c:\temp\", $sFilter, $iFlag)
If @error = 1 Then
    MsgBox(0, "", "0 Files found.")
    Exit
EndIf
Sleep(60000)
For $i = 1 To $FileList[0]
    FileCopy("c:\temp\" & $FileList[$i], "c:\test\" & $FileList[$i])
Next

Thank you, this worked. Also, thanks for everyone else that responded.

I thought since the variable $FileList was set to _FileListToArray that I could just use it that way (an array) without using a loop since it was already defined before the sleep. Thanks for the clarification.

Thanks

Edited by rmarino

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...