Sign in to follow this  
Followers 0
cardguy1000

Move Up X Directories from @ScriptDir

5 posts in this topic

#1 ·  Posted (edited)

Hi guys, I'm semi new to autoit and I can't seem to locate a function to move up X amount of directories. For instances say my script is in C:\test\test2\test3 and I want to run a file within C:\test\difFolder without explicitly declaring C:\test\difFolder, but rather only difFolder declared. So is there a way I could have the script go up 2 directories (regardless of the directories names) then switch to difFolder and execute a given file name?

Something like this...

$filename = 'myFile.exe'

$itsFolder = ''\difFolder\'

$newDir = dirUp(@ScriptDir, 2) ;assuming dirUp is the function name

$newDir = $newDir & itsFolder & $filename

Run($filename)

Edited by cardguy1000

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi guys, I'm semi new to autoit and I can't seem to locate a function to move up X amount of directories.  For instances say my script is in C:\test\test2\test3 and I want to run a file within C:\test\difFolder without explicitly declaring C:\test\difFolder, but rather only difFolder declared.  So is there a way I could have the script go up 2 directories (regardless of the directories names) then switch to difFolder and execute a given file name?

Something like this...

$filename = 'myFile.exe'

$itsFolder = ''\difFolder\'

$newDir = dirUp(@ScriptDir, 2) ;assuming dirUp is the function name

$newDir = $newDir & itsFolder & $filename

Run($filename)

<{POST_SNAPBACK}>

just use \..\

c:\windows\system\..\ = c:\windows\

Func dirUp($s_path, $i_times = 1)
    If $i_times = 0 Then Return $s_path
    $s_path &= '\..'
    For $i = 1 To $i_times
        $s_path &= '\..'
    Next
    Return $s_path
EndFunc  ;==>dirUp
Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Share this post


Link to post
Share on other sites

Hi guys, I'm semi new to autoit and I can't seem to locate a function to move up X amount of directories.  For instances say my script is in C:\test\test2\test3 and I want to run a file within C:\test\difFolder without explicitly declaring C:\test\difFolder, but rather only difFolder declared.  So is there a way I could have the script go up 2 directories (regardless of the directories names) then switch to difFolder and execute a given file name?

Something like this...

$filename = 'myFile.exe'

$itsFolder = ''\difFolder\'

$newDir = dirUp(@ScriptDir, 2) ;assuming dirUp is the function name

$newDir = $newDir & itsFolder & $filename

Run($filename)

<{POST_SNAPBACK}>

My question is why ? I'm not able to see the logic behind your request.

You know the name of the file but not the dir right ?

Why not just search for the file to get the path then execute it ?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

2 directories up.

FileChangeDir('..\..\difFolder')

use @WorkingDir to store the current directory, if needed.

:(

Edited by MHz

Share this post


Link to post
Share on other sites

Thanks guys that's exactly what I was looking for.

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