Page 1 of 1

Getting the name of the opened file

Posted: Mon Sep 22, 2008 9:21 am
by bjb007
A search on this subject gives 14 or so pages
of results which would take quite a while to
read so...

When I open a file with

put URL ("file:" & it) into FileData

how do I get the name of the file that's opened?

Posted: Mon Sep 22, 2008 9:48 am
by Mark
bjb,

Assuming that the it variable contains a valid file name:

Code: Select all

put it into myFilePath
set the itemDel to slash
put last item of myFilePath into myFileName
put URL ("file:" & myFilePath) into myFileData
Best,

Mark

Getting the name of the opened file

Posted: Tue Sep 23, 2008 1:25 am
by bjb007
Thanks Mark.

Wise to add code to save itemDel and
restore after getting the file name else
in my case the file wouldn't load

Code: Select all

put it into myFilePath
put itemDel into someVar
set the itemDel to slash
put last item of myFilePath into myFileName
set itemDel to someVar
put URL ("file:" & myFilePath) into myFileData