Jump to content

Getting The Drive Letter From A Set Variable


Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...