Page 1 of 1

String methods in script: how to get parent folder of file?

Posted: 03 Jan 2023, 19:22
by woodslanding
I'd like to get the parent path of a file. so HH/mystuff/myfile.txt would return HH/mystuff.

I'm not finding much in the docs that's useful. I see a 'pos' command that could be used to find path delimiters, but not sure how to get the location of the last delimiter.

Also no substring methods I can see in the docs, although I think I've scoured delphi resources before and found some things that worked...

Guess I'll dig through old scripts and see what I can turn up.

EDIT:

DOH! should have looked for file methods. I'm assuming this will do it: function ExtractFilePath(const FileName: String): String;

Re: String methods in script: how to get parent folder of file?

Posted: 04 Jan 2023, 08:26
by senso
top+++

Re: String methods in script: how to get parent folder of file?

Posted: 04 Jan 2023, 20:02
by woodslanding
One tiny related bug? fr?

I note that when a file does not have an extension, ExtractFileExtension returns the entire filename, instead of an empty string. Not too hard to work around, but not what I would expect....