Page 1 of 1

filenames and fields

Posted: Sun Jun 14, 2009 5:02 pm
by Damlimey
Hi all,

I want to display in a field, the filename that I have already loaded into a player. I've managed to get the filename into a field but it includes the path to the file, how do I return just the filename and it's extension?

Thanks in advance,

G

Posted: Sun Jun 14, 2009 5:41 pm
by SparkOut
Something like

Code: Select all

set the itemDelimiter to slash
answer file "Choose the file"
put the last item of it into theFileName
if theFileName is not empty then
  -- and whatever other error trapping you need here
  put theFileName into field "theFileNameField"
end if
since Rev uses a slash "/" as its native file path separator, you can use that as the itemDelimiter. If you are working with raw Windows filepaths, then you may need to change "/" to "\" (slash to backslash) or adjust for other file systems as appropriate. If you use the ask file version, then Rev should automatically use the "/" in the path. You can change the itemDelimiter at will, and it will stick for that current handler, and revert to comma after the handler has exited.

Thank you very much

Posted: Sun Jun 14, 2009 6:39 pm
by Damlimey
Thank you Sparkout, that's pushed me on a bit!

G