Jump to content

Return full path of directory


Recommended Posts

Hello guys,

Haven't been here for a long time, and now I have a question, cause searching google and forums didnt made a trick.

So, in this bottom code I got a last folder name (full path is previously written as a value to ini file, where array was used to show all values of a ini section named "Folders", as you see in script below) for my drop-down combo.

Global $combo3 = GuiCtrlCreateCombo("", 10, 200, 100, "", $CBS_DROPDOWNLIST)

Local $var3 = IniReadSection($instruction, "Folders")
If @error Then
    MsgBox(4096, "", "INI file probably corrupted.")
Else

    For $i = 1 To $var3[0][0]
Global $sFullPath = $var3[$i][1]
Global $sLastFolder = StringRegExpReplace($sFullPath, "(.+?\\)*(.+?)(\\.*?(?!\\))", "$4")
GuiCtrlSetData(-1, $sLastFolder)

    Next
EndIf

Then I have to open (presumably, with ShellExecute command) a folder that have been chosen from combobox. I have tryed to do so:

ShellExecute(FileGetLongName(GuiCtrlRead($combo3)))

but succeeded just in few cases (some folders was just impossible to open, with stantard windows error, because full path was not given back!)

Please, can someone be so polite to help me in resolving this problem? Is there something like DirGetLongName ot smth (maybe someone will explain how to use _FullPath() here, because till the moment _FullPath() just returning the full path of ini file, not a full path of folder selected in Combo (prescripted as value for each folder in ini file)!

Maybe somebody will tell how to get back string replaced previously in my script with

Global $sLastFolder = StringRegExpReplace($sFullPath, "(.+?\\)*(.+?)(\\.*?(?!\\))", "$4")
??? This would be full path that I am searching for.

Thx a lot to all.

Edited by electrico
Link to comment
Share on other sites

You are talking about _PathFull?

Can you post how you called this function?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Can you please tell me by giving an example

  • what the user selects from the combobox
  • what the full path should the be based on the selection
  • what the working directory for the script is

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thx for trying to deal with my problem.

1) From combobox users select folder that further must be opened with button (or other control).

2) In combobox only last folders should be displayed, however script command ShellExecute that I use next, should use whole path, not only selected value (last folder name), - to open the folder.

3) script working directory is @DesktopDir, but values are descripted in ini file that i keeping in my flash drive.

Please, for deeper understanding what I mean, and also for useful helping, I attach whole my script, where problem is at lines: 741 - 743 (func _open_personal_folder())

Thanks for any attention.

startp.au3 - Copy.au3

Edited by electrico
Link to comment
Share on other sites

Thanks for posting the code. Quite long and needs some additional UDFs.

I can't test in the moment so I'm going to ask a few questions:

Does the user select e.g C:foldersubfoldersubsubfolder or just subsubfolder from the ComboBox?

If the 2nd is true: Should the full path be @DesktopDir & "subsubdir" or does your script read the rest of the path from the ini file?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Code is long and script is hardcoded - this is my ugly programming style :)

Answers: 1) - yes, they see just subfolder, whole path would be too long and ugly :)

2) If it would be just @DesktopDir I would not write a post here, but script must read the whole path from the ini file, (handling the option selected by user from combobox, dropdown, that is last subfolder in path - yes, you understood correctly!) I just was searching how to get back the whole path that was prevously cut till last subfolder by expression StringRegExpReplace......... (see my first msg in this post).

Thx.

Link to comment
Share on other sites

This searches the full path from the right side until a "\" is found and takes the folder from there.

Means: Returns "subsubfolder" from "C:\folder\subfolder\subsubfolder"

$fullpath = "C:\folder\subfolder\subsubfolder"
$folder = StringMid($fullpath, StringInStr($fullpath, "\", 0, -1) + 1)
ConsoleWrite($folder & @LF)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Yes, this is another way how to take last subfolder. But in my case I would like to know how to return whole path from this subsubfolder.

And this is not the prevously declared path with vairable or smth.. it is user's choice from combobox.. So, after user choose from dropdown this "subsubfolder" as you said, this subsubfolder must be converted back to full path that indicated in ini file as value... (as u see in my script from lines 741 - 743). Anyways, even if you do not want to go deep... thx for paying attention.

Edited by electrico
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...