Get filename full path

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
CenturyMan1979
Posts: 86
Joined: Tue May 15, 2012 5:56 pm

Get filename full path

Post by CenturyMan1979 » Fri Jun 15, 2012 6:06 pm

So I have a small script that I call to get the list of file in a particular directory,

Code: Select all

function getListOfFiles pDir
   
   local tOldDir, tFiles
   
   put the directory into tOldDir
   set the directory to pDir
   put the files into tFiles
   set the directory to tOldDir
   return tFiles
   
end getListOfFiles
Only thing is that the returned files are only the names of the files. Is there some way of getting the list with full paths without appending it in the function myself? Some paths are relative and others are absolute if that makes a difference.

Klaus
Posts: 14213
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Get filename full path

Post by Klaus » Fri Jun 15, 2012 6:37 pm

Hi CenturyMan1979,
CenturyMan1979 wrote: Is there some way of getting the list with full paths without appending it in the function myself?
in short, no 8)

"the files" always returns the bare filenames, you need to take care of adding the missing part of the absolute filename.


Best

Klaus

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Get filename full path

Post by jmburnod » Fri Jun 15, 2012 6:41 pm

Hi CenturyMan1979,

You can use a custompropertie of a control or a local variable to keep the path of the folder

Best regards

Jean-Marc
https://alternatic.ch

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Get filename full path

Post by BvG » Fri Jun 15, 2012 6:55 pm

put the directory & "/" & line 1 of the files --i prefer to use 'the defaultFolder' because it describes better what it contains, but whatever works :)
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Get filename full path

Post by mwieder » Fri Jun 15, 2012 7:35 pm

without appending it in the function
Is there some reason you need to avoid this?

CenturyMan1979
Posts: 86
Joined: Tue May 15, 2012 5:56 pm

Re: Get filename full path

Post by CenturyMan1979 » Fri Jun 15, 2012 7:41 pm

mwieder wrote:
without appending it in the function
Is there some reason you need to avoid this?
Just curious if there was something out there already that could be used like, put the filepath & itemDel & the filename of me . Turns out there is not.

Post Reply