Jump to content

Get Path From String


kalans
 Share

Recommended Posts

Hello, I have look around for a function and used search to find my exact answer but no luck.

I have a location of a file (string), but need to know the directory the file is in.

Example:

"C:Program Files (x86)The DirThe File.exe"

and I need it to be

"C:Program Files (x86)The Dir"

But I can't do any trimming, due to if they have a different name on the exe "TheFile.exe". Now I can get rid of the .exe part by using StringReplace but I do not know where to go from here XD.

Help would be most appreciated! Thanks!

Edited by kalans
Link to comment
Share on other sites

Function _PathSplit does what you need:

"Splits a path into the drive, directory, file name and file extension parts."

You then simply concatenate the parts you need: drive and directory.

BTW:

keyword "game" might trigger some unpleasant reactions. Be sure you carefully read the forum rules!

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

What's wrong about _PathSplit?

All you have to do it to put the pieces together.

A word of advice: be careful about any game related issue; if you haven't read the forum rules yet, I would suggest reading them asap.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

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...