Hi All,
I came across a very versatile tool developed by the late Mark Smith, called id3lib.
When I use this tool while gathering info about more than one mp3-files the output is not adequate: only the data of the first mp3-file is presented. I tried the following script:
on mouseUp
set the itemDelimiter to slash
put item 1 to -2 of the effective filename of this stack into stdFolder
set the defaultFolder to stdFolder & "/" & "MyFiles"
put the files into theFiles
filter theFiles with "*[.mp3]"
set defaultFolder to stdFolder
start using stack "id3lib"
repeat for each line K in theFiles
id3_setFile ("MyFiles" & "/" & K)
set the clipboardData["rtf"] to id3_getArtist() & tab & id3_getTitle() & tab & id3_getAlbum() & tab & id3_getYear()
put the clipboardData & cr after tData
end repeat
delete last char in tData
put tData into fld 1
end mouseUp
How can I get the info of all the files in MyFiles?
Kind Regards,
JanVledder
How to handle data from mp3-files
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 7258
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: How to handle data from mp3-files
I'm not familiar with the library but it doesn't look like you need to go through the clipboard to collect the data. This should work:
Does the library return info as rtf, and that's why you're using the clipboard to convert it to plain text? If so, the last line could be:
That doesn't explain why only the first file is processed. You could add a breakpoint to see how many lines are returned in the file list.
Code: Select all
repeat for each line K in theFiles
id3_setFile ("MyFiles" & "/" & K)
put id3_getArtist() & tab & id3_getTitle() & tab & id3_getAlbum() & tab & id3_getYear() & cr after tData
end repeat
delete last char of tData
put tData into fld 1
Code: Select all
set the rtfText of fld 1 to tData
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 3
- Joined: Sun Dec 12, 2021 9:39 pm
Re: How to handle data from mp3-files
Thank you for your quick response. I changed the script and that works well, except for one thing: the cr doesn't result in a new line, so everything in fld 1 is one line. Could you tell me how to fix this? I use an Apple MacBook Pro with intel processor and MacOS Monterey.
Thanks in advance
JanVledder
Thanks in advance
JanVledder
-
- VIP Livecode Opensource Backer
- Posts: 7258
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: How to handle data from mp3-files
You didn't mention whether the library returns rtf text, but if so you'd want to use the rtf version of a carriage return instead of LC's cr constant. I couldn't find a definitive answer after a cursory search but try "\n" for starters. Maybe someone here knows more about the file format.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 3
- Joined: Sun Dec 12, 2021 9:39 pm
Re: How to handle data from mp3-files
I'm sure the output is RTF text. After you mentioned trying "\n" (which didn't work, the output was empty) I tried other 'commands', "\par" and "\line" are candidates. After a lot of trial and error I ended up with "\par1" and "\line1" that do the trick. I don't understand why this is working, but it works!
So thank you for guiding me to this solution. ('Dankjewel' in Dutch).
Kind regards,
JanVledder
So thank you for guiding me to this solution. ('Dankjewel' in Dutch).
Kind regards,
JanVledder