Page 1 of 1

Extracting filenames without extension to a variable

Posted: Thu Oct 03, 2013 10:48 am
by HansImGlueck
Hi all,

this is my first posting here. I found, that Livecode is really a great tool to learn basic programming skills. I'm gonna use it for programming a simple client, which communicates via TCP and plain text expressions with a video server...
Now the problem:
In those plain text commands I need the file names of files in a folder WITHOUT extensions! The server doesn't accept "video.mov", but only "video".
How can I fill a list field with the file names in a specific folder without extensions (.mov, .mp4, .avi...). From the tutorials I know to browse to a folder and show the contents in a list field. In addition I know how to select a specific file and put it's file name to a variable to work with. What I don't know is, how to shorten the file name of it's extension.
Yes - I've used the search-function here, but didn't find an answer...

Thanks,
Martin

Re: Extracting filenames without extension to a variable

Posted: Thu Oct 03, 2013 11:00 am
by Klaus
Hi Martin (a.k.a. HansimGlück),

1. welcome to the forum! :D

2. "itemdelimiter" is your friend!
One way to do so:
...
put "filepath/folder/file.suffix" into tFileWithoutSuffix
set itemdel to "."
delete item -1 of tFileWithoutSuffix
## -1 = the last
answer tFileWithoutSuffix
## -> filepath/folder/files
...

Best

Klaus

Re: Extracting filenames without extension to a variable

Posted: Thu Oct 03, 2013 12:22 pm
by HansImGlueck
Hi Klaus,

thank you very much for your instant reply!
I just tried it, and now it works perfect - great!
This topic can be marked as solved.

Thank's again, Martin

Re: Extracting filenames without extension to a variable

Posted: Thu Oct 03, 2013 12:45 pm
by Klaus
War mir ein Vergnügen! :D