Jump to content
Sign in to follow this  
JohnSte

FileExist with array

Recommended Posts

Greetings,

Thanks to some very helpful previous advice I have made some headway with my script. But I'm either missing something obvious (likely) or not coding the script correctly (also likely). When I compile and run this, I get an error "Line 2789, Error: Error parsing function call."

The script:

#include <Array.au3>

#include <File.au3>

#include <MsgBoxConstants.au3>

$FileListArray = _FileListToArray ("C:Windows")

$FileListTArray= _FileListToArray ("C:Test")

For $FileList in $FileListArray;

If Not FileExist($FileList) in $FileListTArray Then

DirCreate($FileList) in $FileListTArray)

EndIf

Next

Basically all I want to do is check if each file (directory) in the first directory exists in the second, and if not, create it, running through the list of files (directories) in the first array.

Any help greatly appreciated!

Share this post


Link to post
Share on other sites

Start with removing the in $FileListTArray) from the end of your DirCreate line..

Actually, looking at the code more closely, there are more issues.. Correct me if I am wrong, but you're wanting to create an array of all files in C:Windows, and then if that directory does not exist in C:Test create it? Maybe something more like this.

#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

$aList = _FileListToArray("C:\WIndows", Default, $FLTA_FOLDERS)
$anewList = _FileListToArray(@DesktopDir & "\Test", Default, $FLTA_FOLDERS)

    For $dir In $aList
        For $newDir In $anewList
            If Not FileExists($dir) Then DirCreate(@DesktopDir & "\Test\" & $dir)
        Next
    Next
Edited by JLogan3o13

Share this post


Link to post
Share on other sites

Thanks, JohnOne - I was wondering why it's running and I'm not seeing any results :*

Is there a way to get it to look at the directory from elsewhere, as opposed to needing to be in the path?

and I need the $iflag option with FLTA_FOLDERS to exclude the files, it appears.

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  

×
×
  • Create New...