Jump to content

Using an array inside of an array to transfer lots of files.

Go to solution Solved by TheAlienDoctor,

Recommended Posts

Hi, I was looking into creating a script that would detect if a file exists, then move it (and in some cases rename it, depending on the file) as well as write to a log file.

The issue is, there is a lot of files that need to be moved, sometimes some files will exist and others won't depending on the use-case. However if a file does exist, it will always be going into the same directory with the same name.

Currently I have an array nested inside of the array, with each array inside that array having both the old and new directory, and then a For loop to actually run through and do the file transferring. The issue I am having is how to call the Array inside of the array, because how do I specify  which the old directory is and which the new is?

Global $FileTransfer[2000] = [Global $Dir1[2] = ["original dir 1", "new dir 1"], Global $Dir2[2] = ["original dir 2", "new dir 2"]]

For $FileTransfer = [0] To [1] Step +1
    If FileExists({original dir}) Then
        FileMove({original dir}, new dir, 1)
        FileOpen("log.latest.txt", 1)
        FileWrite("log.latest.txt", "{original dir} found, moved it to new dir." & @CRLF)
        FileOpen("log_latest.txt", 1)
        FileWrite("log_latest.txt", "{original dir} not found, ignoreing it." & @CRLF)

I have put what I want the old and new directory to be for each array in {}, so hopefully its easier to tell which part is working and whats not.

I am still reasonably new to AutoIT, any help is appreciated. Thankyou :)

Edited by TheAlienDoctor
TO be more clear
Link to comment
Share on other sites

  • Solution

I believe to have found the solution by using a temporary variable thanks to my friend litterally minutes after posting this, sorry for wasting anyone time. Hopefully someone else can use this info though. Its similar to this post: 

Thank you, and sorry if you feel that I have wasted your time.

Edited by TheAlienDoctor
Adding solution
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

  • Create New...