Sign in to follow this  
Followers 0
Squirrely1

Extract Directory Name

8 posts in this topic

#1 ·  Posted (edited)

Attached is a set of functions to extract the directory name or filename given a complete filepath, and another to make a typed-in path to be valid. Comments and suggestions are welcomed. See "Link . . . Path.au3" below. :D

Link to the updated Path.au3 download page (AutoIt Scripts & Scraps)

These includes files have been updated to fix a glitch wherein a trailing backslash specified by a switch didn't work right if the folder was a driveletter followed only by a colon. ( _StringExtractDirectory lines 232 -256 )

Edited by Squirrely1

Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites



This is also available in Beta.

_PathSplit

--------------------------------------------------------------------------------

Splits a path into the drive, directory, file name and file extension parts. An empty string is set if a part is missing.

Share this post


Link to post
Share on other sites

Thanks for the heads up Manadar. I like your 3D.au3. There are so many new functions in the betas I get lost. I wondered why nobody had come up with functions like the first two in my .au3. I had been using those for quite a while and so started fixing them up. What do you think of the idea of a function that checks the validity of a typed-in path, like my third function is supposed to do. Can you fool that function and find any flaws that it may have?


Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Are you kidding me? :wacko:

The functions may already exist, but yours are solid as a rock.

For the function that checks wether a path is good and exists. I would suggest that you do a FileOpen with write flag, but not create directory flag, if the path doesn't exist it will probably return -1. If it doesn't return -1, FileDelete.

Three thumbs up for the great scripting job :D

Edited by Manadar

Share this post


Link to post
Share on other sites

Thanks for the encouragement Manadar, I have made a note in that file of what you say to try, and the next time I work on that module, I want to make sure to check it out your tweak.

:D


Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

Hi,

Using

#include <Path.au3>

; ----------------------------------------------------------------------------
; Setup Default Variables
; ----------------------------------------------------------------------------
Local $entries_ini 
Local $Folder


; ----------------------------------------------------------------------------
; Script Start
; ----------------------------------------------------------------------------

; ----------------------------------------------------------------------------
; Get Folder Entries.ini is in
; ----------------------------------------------------------------------------
$Folder = _StringExtractDirectory ("H:\ISOs\SOURCES\AutoImage\Tools\FGCBA\AttributeChanger_v5.23_Addon\Entries_ini")

; ----------------------------------------------------------------------------
; Run FGCBA
; ----------------------------------------------------------------------------
$PID = Run(@ComSpec & ' /c ' & 'FGCBA ' & '"$entries_ini"' & ' /cab:' & '"$Folder' & '.cab"', @ScriptDir)
ProcessWaitClose ($PID)

I get the follwing error:

Line 208: File Path.au3

SetError (0,0)

ERROR^

Any help appreciated,

niche99

Share this post


Link to post
Share on other sites

Hi,

Using

#include <Path.au3>

; ----------------------------------------------------------------------------
; Setup Default Variables
; ----------------------------------------------------------------------------
Local $entries_ini 
Local $Folder
; ----------------------------------------------------------------------------
; Script Start
; ----------------------------------------------------------------------------

; ----------------------------------------------------------------------------
; Get Folder Entries.ini is in
; ----------------------------------------------------------------------------
$Folder = _StringExtractDirectory ("H:\ISOs\SOURCES\AutoImage\Tools\FGCBA\AttributeChanger_v5.23_Addon\Entries_ini")

; ----------------------------------------------------------------------------
; Run FGCBA
; ----------------------------------------------------------------------------
$PID = Run(@ComSpec & ' /c ' & 'FGCBA ' & '"$entries_ini"' & ' /cab:' & '"$Folder' & '.cab"', @ScriptDir)
ProcessWaitClose ($PID)

I get the follwing error:

Line 208: File Path.au3

SetError (0,0)

ERROR^

Any help appreciated,

niche99

niche99, it looks as though you are using an altered version of my UDF, named "File Path.au3". If so and you want to continue doing so, you should use this: "#include <File Path.au3>" instead of "#include <Path.au3>". Cheers! :whistle:


Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

I get the follwing error:

Line 208: File Path.au3

SetError (0,0)

ERROR^

Any help appreciated,

niche99

You maybe getting the error as the latest Beta functions and syntax is being used in the scripts. :)

@Squirrely1

Path.au3 is the "File" in the error message. :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