ganeshk225 Posted July 23, 2012 Share Posted July 23, 2012 Hi,I've been using AutoIt for around a month and have found it very useful Have been able to automate most of the tasks I wanted to.I have encountered a hiccup and not sure how to get this working.Suppose there is a folder by name - ConfigurationFolder - in the same directory where my autoscript is present. Inside this folder, there is a file, logfile.txt.There is an excel sheet which has the data regarding the folder name (ConfigurationFolder) and the file name (logfile.txt). I have an autoit script which reads the excel, captures this information in two variables... say $folder has the folder name and $file has the file name.Something like... $folder = ConfigurationFolder $file = logfile.txtI would be using these two variables to check if the directory exists and check is the file exists. Then make use of the file.For that, first I need to be able to use the variables as part of the directory path.Suppose my autoit script is in the location - C:\Users\script.au3When I try the below autoit script to assign the full path in the variable - $Directory, it doesn't work.$Directory = @ScriptDir & "\$folder\$file""\$folder\$file" remains as it is, i.e., it gets translated to C:\Users\$folder\$file and not C:\Users\ConfigurationFolder\logfile.txtCan someone please help me out here?Cheers,Ganesh Link to comment Share on other sites More sharing options...
Exit Posted July 23, 2012 Share Posted July 23, 2012 (edited) $Directory = @ScriptDir & "" & $folder & "" & $file Edited July 23, 2012 by Exit App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
GajjarTejas Posted July 23, 2012 Share Posted July 23, 2012 $Directory = @ScriptDir & "$folder$file" is not correct but $Directory = @ScriptDir & "" & $folder & "" & $filewhich correctalso read help file -->FAQ Link to comment Share on other sites More sharing options...
Exit Posted July 23, 2012 Share Posted July 23, 2012 There is also a second method. See this script. $folder = "myFolder" $file = "myFile" $Directory1 = @ScriptDir & "" & $folder & "" & $file Opt("ExpandVarStrings", 1) $Directory2 = "@ScriptDir@$folder$$file$" MsgBox(262144,"",$Directory1 &@LF & $Directory2,0) App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
ganeshk225 Posted July 23, 2012 Author Share Posted July 23, 2012 Thanks a lot for the quick response both methods work just fine!! 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