Jump to content
Sign in to follow this  
JohnSte

FileExist with array

Recommended Posts

JohnSte

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
JLogan3o13

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

√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
JohnSte

so it should be

DirCreate($filelist) in C:Test

?

Share this post


Link to post
Share on other sites
JohnSte

Thanks for the sample. Yes, I think you understand what I'm trying to do. I'll give this a whirl!

Share this post


Link to post
Share on other sites
JohnSte

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
JLogan3o13

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?


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
JohnSte

Sorry, that was poorly worded. What I meant is, is it possible to run the script from somewhere other than C:Windows?

Share this post


Link to post
Share on other sites
JLogan3o13

You can run the script from anywhere, so long as you have the paths coded. I ran my example from my Desktop and it worked just fine.


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
JohnSte

Thank you, everyone. That is exactly what I needed.

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  

×