Sign in to follow this  
Followers 0
Diana (Cda)

Virtual vs. absolute paths in scripts?

4 posts in this topic

I've tried to modify AI coding to get items to open regardless of the drive letter.

In the case of applications, so that it opens items contained in the folder the script is in a folder that is also contains the script folder (1); or in the case of the thumb drive, dealing with opening items, etc., regardless of the drive letter the thumb drive is on (2).

I've not had any success so far. It would make life vastly easier to be able to do this.

How do we approach this issue in AI, if it can be done?

1) For example, so that AI deals with items contained in same folder as script or a couple of folders away:

the scripts are here

D:\AI scripts\scripts\Scripts

and the wav files are here

D:\AI scripts\scripts\WAVs

so that this

SoundPlay ("D:\AUTOIT\Scripts\WAVs\EsyWb.wav")

will work as this

SoundPlay ("AUTOIT\Scripts\WAVs\EsyWb.wav")

or this, etc.

SoundPlay ("WAVs\EsyWb.wav")

When I moved to new computer, I had a massive job. Granted I used found midway a bulk string search+replace but it will still a job. <g>

instead of having to type in the entire path, that we just deal with the folders, etc., like this:

AI scripts\WAVs

and second case,

2) To make this type of command ...

Run('E:\APPS\metapad.exe "E:\LOG ENTRIES\Daily error log entries.txt"')

not dependent on the drive letter ...

Run('\APPS\metapad.exe "\LOG ENTRIES\Daily error log entries.txt"')

... so that it works no matter what computer I log on to to do work from.

Thanks. Much appreciated. :whistle:

Share this post


Link to post
Share on other sites



I've tried to modify AI coding to get items to open regardless of the drive letter.

In the case of applications, so that it opens items contained in the folder the script is in a folder that is also contains the script folder (1); or in the case of the thumb drive, dealing with opening items, etc., regardless of the drive letter the thumb drive is on (2).

I've not had any success so far. It would make life vastly easier to be able to do this.

How do we approach this issue in AI, if it can be done?

1) For example, so that AI deals with items contained in same folder as script or a couple of folders away:

the scripts are here

D:\AI scripts\scripts\Scripts

and the wav files are here

D:\AI scripts\scripts\WAVs

so that this

SoundPlay ("D:\AUTOIT\Scripts\WAVs\EsyWb.wav")

will work as this

SoundPlay ("AUTOIT\Scripts\WAVs\EsyWb.wav")

or this, etc.

SoundPlay ("WAVs\EsyWb.wav")

When I moved to new computer, I had a massive job. Granted I used found midway a bulk string search+replace but it will still a job. <g>

instead of having to type in the entire path, that we just deal with the folders, etc., like this:

AI scripts\WAVs

and second case,

2) To make this type of command ...

Run('E:\APPS\metapad.exe "E:\LOG ENTRIES\Daily error log entries.txt"')

not dependent on the drive letter ...

Run('\APPS\metapad.exe "\LOG ENTRIES\Daily error log entries.txt"')

... so that it works no matter what computer I log on to to do work from.

Thanks. Much appreciated. :whistle:

If you have the data in the same folder as the script, can't you just use @ScriptDir as part of your path? Or am I missing what you are trying to do?

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

If the scripts are here

D:\AI scripts\scripts\Scripts

and the wav files are here

D:\AI scripts\scripts\WAVs

then instead of

D:\AI scripts\scripts\WAVs

use

..\WAVs

or better

@scriptdir\..\WAVs

To find the drive letter for your thumb drive, first you could put a file in the root of the thumb drive with a special name say Unique_filename.kkk.jjj

Then find a list of all available removable drives,

$posdrives = DriveGetDrive ( "removable" )

then go through the drives with something like

for $dn = 1 to $posdrives[0]

if fileExists($posdrives[$dn] & '\Unique_filename.kkk.jjj) then

exitloop

next

and now the drive letter = $posdrives[$dn]


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

If the scripts are here

D:\AI scripts\scripts\Scripts

and the wav files are here

D:\AI scripts\scripts\WAVs

then instead of

D:\AI scripts\scripts\WAVs

use

..\WAVs

or better

@scriptdir\..\WAVs

Excellent! So all I was missing was ".." when I'd tried last year via trial and error to make something not based on a full path.

Interestingly enough "..\WAVs" and "@scriptdir\..\WAVs" didn't actually work. It took "..\Scripts\WAVs" to do the trick [(?) go figure <g>]. So I guess AI just needs a bit more of the original path.

I'll report back re the thumb drive. I'll be fiddling with the paths later on today and will advise results.

Thanks. I really, really appreciate this.

Cheers. :whistle:

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