Sign in to follow this  
Followers 0
AlternateExistance

Getting The Drive Letter From A Set Variable

7 posts in this topic

Hi guys,

I am more of a batch person but am migrating over to AutoIT as it is far more scalable, however i am currently having difficultly with a small problem.

I am having trouble trying to determine the drive letter of a set variable which was set as a directory path.

For eg, if $dest = 'Z:\TEMP FILES', how would i go about determining the drive that set variable was using was the Z drive?

In batch i would have written the following:

@ECHO OFF

SET DEST=Z:\TEMP FILES

CD /D %DEST%

CD\

SET DRIVE=%CD%

ECHO THE DRIVE LETTER OF %DEST% FOLDER IS: %DRIVE%

Thanks,

Liam

Share this post


Link to post
Share on other sites



Hehe, yeah, you need to think more in a high-level-language mindframe, instead of batch programming.

Batch programming is waayy too funky !

Share this post


Link to post
Share on other sites

Thanks JackDinn, that did the trick very nicely!

Inverted, you are definitely right about that! Batch is funky but i am working towards getting into something with more meat - namely AutoIT.

I have a long way to go it seems...

Thanks again,

Liam

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

are you just wanting to get the "Z:" from the string? if so then use StringLeft($dest,2)

to get the patch from a var i would prefer pathsplit ^^

here a example

#include <file.au3>
#include <array.au3>
Dim $szDrive, $szDir, $szFName, $szExt
_PathSplit($var, $szDrive, $szDir, $szFName, $szExt)
then you will get the path with $szDrive&"/"&$szDir

more confinient and always returns the correct values :)
Edited by unixu

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

yea sure but you just using the same command , if you look inside _PathSplit() you find := $drive = StringLeft($szPath, 2)

so you dont really need to #Include all that extra stuff

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

well i dont like these stringleft and stringright stuff ^^

i like it to work with self written functions and those stringleft and right i cannot really use them in my function so i use the _pathsplit stuff :D

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