Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How do you get a file name out of a path name?

Featured Replies

I've been trying to get a file name from the end of a path name (on Windows) with the following formula:

Right (pathFile ; Position (pathFile ; "" ; Length (pathFile ) ; -1 ) )

The problem is that the backslash ()used in Windows file paths is rejected by the calculation dialog when I try to save the calculation. How can I get around this?

Any help is appreciated.

Since a backslash is actually an escape character itself (it is escaping the " in your calculation), then you need to put 2 when you want a backslash in your calculation.

Right (pathFile ; Position (pathFile ; "" ; Length (pathFile ) ; -1 ) )

  • Author

Thanks, Fenton. Now the calc dialog accepts it but...the calculation doesn't work. The Length() seems to return the inverse of what I want. Any ideas why?

Post a copy of what you are working with, and what you wont' to parse out.

HTH

Lee

I have used the following two calculations, WinURL is the fully specified file and path name returned by FMP from a getAsText(file) where file is a container containing a file reference.

filepath =

Left(WinURL;Position(WinURL;"";0;PatternCount ( WinURL ;"" )))

filename = Right(WinURL; Length(WinURL) - Length(File Path))

I can't see why this should work and yours not.

  • Author

Hi Lee,

Here's a sample file of what I'm trying to do. Something is obviously wrong with my calc but I can't figure it out. Hopefully you can show me where I've erred.

Hi Slim Jim,

I'm going to give your calculations a try also, but first I want to find out where the error lies in the way I'm attempting to parse the name out.

Thanks to all!!! :

PathNameParse.zip

  • Author

Nicely done, Paul. I realize now where my logic wasn't correct. And setting the "occurrence" parameter in Position() by using the PatternCount value of "" is (in my humble opinion) a superior approach to my attempt to search backward in the Position() function.

Many thanks!!!

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.