Sign in to follow this  
Followers 0
craigey1

Parent Directory from @ScriptDir

9 posts in this topic

#1 ·  Posted (edited)

Hi All,

I'm Having some difficulty Navigating Folders & was hoping someone could help out.

I Have a directory structure something like:

(please ignore the ".")

....<.......CD.........>

..|...........................\

..|.............................\

..|..............................\

Folder A................Folder B

..|...............................|

SCRIPT .au3...........FILE.vbs

I can get the current script path using "@ScriptDir", but I'm having difficulty trying to navigate to "Folder B". When I was using vbscript I was using the function INSTREV like so:

UponeFolder_tmp = Left(script_path, InstrRev(script_path, "\")-1)
UponeFolder = Left(UponeFolder_tmp, InstrRev(UponeFolder_tmp, "\"))

Any ideas / advice as to how I can do this with AutoIT?

Thanks in Advance

Edited by craigey1

Share this post


Link to post
Share on other sites



Thanks will give it a shot tomorrow sometime, it's 2am & I've had enough of staring at my dodgy code! Time for bed!

Share this post


Link to post
Share on other sites

Like this:

Msgbox(0,'This will open "Folder B"',@Scriptdir & "\..\Folder B")

Msgbox(0,"Text Data",FileRead(@Scriptdir & "\..\Folder B\Test.txt"))

Place Test.txt in Folder B with a line of text and you will see that it works.


"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
Share on other sites

Thanks Both of You. 2nd option is definately easier to use, though!

Thanks again

Share this post


Link to post
Share on other sites

Ok, it sounds like it's solved, but I thought it would be interesting to mention that there's something simular in AutoIt as the "INSTREV" in VB

StringInStr ( "string", "substring" [, casesense [, occurrence]] )

When you use the StringInStr function with a negative occurence it starts searching from the right of the string.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

You should use the function "_PathFull":

#include 'file.au3'
$FullPath = _PathFull("..\Folder B", @Scriptdir)
Msgbox(0, 'This will open "Folder B"', $FullPath)oÝ÷ Ù«­¢+Øìôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôô(ì(ìÍÉ¥ÁÑ¥½¸è$QÉÑ̸¸ÀäÈìÌIÑÕɹÌÁÑ ÑÈÁɽÍÍ¥¹Ñ¡¥ÉѽÉ䡹½ÁÉѽȸ¸Ñ¼µ½ÙÑ¡ÁÑ ÕÀ(ì$$$$$$$%½¹±Ù°¸(ìMå¹Ñàè$$}AÑ¡Õ±° ÀÌØíÍI±Ñ¥ÙAÑ °ÀÌØíÍ    ÍAÑ ô]½É­¥¹¥È¤(ìAɵÑȡ̤è$ÀÌØíÍI±Ñ¥ÙAÑ ´Q¡ÁÑ Ñ¼ÁɽÍ̸(ì$$$$$$$ÀÌØíÍ ÍAÑ ÀÌØíÍQåÁ´ÍÁÑ Ñ¼ÕÍ¥¸Í½±ÕÑÁÑ ¥Ì¹½ÐÁɽ٥¸Q¡¥ÌÕ±ÑÌѼѡ(ì$$$$$$$%ÕÉɹÐݽɭ¥¹¥ÉѽÉä¸(ìIÅեɵ¹Ð¡Ì¤è9½¹(ìIÑÕɸY±Õ¡Ì¤èQ¡áÁ¹ÁÑ °Ñ¡É½½ÐÉ¥Ù½ÈÀÌØíÍ   ÍAÑ Á¹¥¹½¸¡½Ü¥ÐÌäí̱±¸(ìÕÑ¡½È¡Ì¤è$%Y±¥¬¡=É¥¥¹°Õ¹Ñ¥½¸¹µ½¥¥Ñ¥½¸Ñ¼ÉÝɥѤ(ì$$$$$%Ñ¥ÑѽÁɽ©Ð¡IÝɥѤ(ì9½Ñ¡Ì¤è$$U9ÁÑ¡ÌÉÍÕÁÁ½ÉѸ(ì$$$$AÍÌÅÕ½ÐìÀäÈìÅÕ½ÐìѼÐѡɽ½ÐÉ¥Ù½ÀÌØíÍ ÍAÑ ¸(ì$$$$AÍÌÅÕ½ÐìÅÕ½Ðì½ÈÅÕ½Ðì¸ÅÕ½ÐìѼÉÑÕɸÀÌØíÍ  ÍAÑ ¸(ì$$$$ɱѥÙÁÑ Ý¥±°Õ¥±ÐɱѥÙѼÀÌØíÍ  ÍAÑ ¸Q¼åÁÍÌÑ¡¥Ì¡Ù¥½È°Õ͸ͽ±ÕÑÁÑ ¸(ì(ìôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôô
Edited by tittoproject

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  
Followers 0