JohnSte Posted September 2, 2014 Share Posted September 2, 2014 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! Link to comment Share on other sites More sharing options...
Moderators Solution JLogan3o13 Posted September 2, 2014 Moderators Solution Share Posted September 2, 2014 (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 September 2, 2014 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! Link to comment Share on other sites More sharing options...
JohnOne Posted September 2, 2014 Share Posted September 2, 2014 (edited) Probably need to add path too. Edited September 2, 2014 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnSte Posted September 2, 2014 Author Share Posted September 2, 2014 so it should be DirCreate($filelist) in C:Test ? Link to comment Share on other sites More sharing options...
Wruck Posted September 2, 2014 Share Posted September 2, 2014 (edited) Check the docs on the command: https://www.autoitscript.com/autoit3/docs/functions/DirCreate.htm You cannot put anything at the end of the line after the function and param. Edited September 2, 2014 by Wruck Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 2, 2014 Moderators Share Posted September 2, 2014 JohnSte, see the example I ammended to my post. That works well for me. "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! Link to comment Share on other sites More sharing options...
JohnSte Posted September 2, 2014 Author Share Posted September 2, 2014 Thanks for the sample. Yes, I think you understand what I'm trying to do. I'll give this a whirl! Link to comment Share on other sites More sharing options...
JohnOne Posted September 2, 2014 Share Posted September 2, 2014 _FileListToArray in your code will get both files and folders, and your file exists test will only work if your script is in Windows dir. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnSte Posted September 2, 2014 Author Share Posted September 2, 2014 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. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 2, 2014 Moderators Share Posted September 2, 2014 You are quite correct, J1, I should have been less liberal with copying and pasting the OP's code. Fixed my post above "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! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 2, 2014 Moderators Share Posted September 2, 2014 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! Link to comment Share on other sites More sharing options...
JohnSte Posted September 2, 2014 Author Share Posted September 2, 2014 Sorry, that was poorly worded. What I meant is, is it possible to run the script from somewhere other than C:Windows? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 2, 2014 Moderators Share Posted September 2, 2014 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. "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! Link to comment Share on other sites More sharing options...
JohnSte Posted September 2, 2014 Author Share Posted September 2, 2014 Thank you, everyone. That is exactly what I needed. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now