Jump to content

FileExist with array


Go to solution Solved by JLogan3o13,

Recommended Posts

Posted

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!

  • Moderators
  • Solution
Posted (edited)

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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

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.

  • Moderators
Posted

JohnSte, what do you mean "look at the path from elsewhere". Are you meaning reading your path from a variable, or an external source like a file?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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