Monday, October 23, 2017

#76 2017-05-03 02:41:39 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4412

Re: Applescript to read mp3 metatags and sort file into folder

I think the \U00bb comes from using the shell script version of the script:

Applescript:


-- With squigee90's file selected in the Finder:
tell application "Finder" to set selectedItem to beginning of (selection as alias list)

do shell script "mdls -raw -name kMDItemAuthors " & quoted form of POSIX path of selectedItem
(*
--> "(
\"A.Squared \\U00bb download-techno.com\"
)"
*)


do shell script "mdls -raw -name kMDItemTitle " & quoted form of POSIX path of selectedItem
--> "Third Eye (Original Mix) » download-techno.com"

With the ASObjC version, it doesn't happen.


NG

Offline

 

#77 2017-05-03 03:55:03 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3201

Re: Applescript to read mp3 metatags and sort file into folder

Sure, the shell version behaves this way but I missed that the asker gave the history with the logged "point xx" which I inserted only in the ASObjC version.

It fails to execute the instruction :
set metaItem to (theQuery's resultAtIndex:0)

Introducing a new filter change nothing to this problem.
I will remove it and will try to intercept the error.
I wrote "try" because as I can't reproduce the problem I'm in the fog.

The script in message #53 is edited accordingly.

Yvan KOENIG running Sierra 10.12.4 in French (VALLAURIS, France) mercredi 3 mai 2017 10:54:57

Last edited by Yvan Koenig (2017-05-03 04:16:06 am)

Offline

 

#78 2017-05-03 06:21:23 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4412

Re: Applescript to read mp3 metatags and sort file into folder

Hi Yvan.

There are two different problems here, one caused by the other.

1. The OP's problem file is one on which he'd run the script previously:

In post #70, squigee90 wrote:

When the script sorted it previously, it put some weird stuff in the title.


I think the script he used was one based on the mdls shell script. It renamed the file {125-Bbm}  A.Squared \U00bb download-techno.com - Third Eye (Original Mix) » download-techno.com.mp3.

2. When the file has \U00bb in its name, the metadata query in the ASObjC script, for unknown reasons, doesn't return any results for it, causing resultAtIndex:0 to error:

In post #73, I wrote:

However, renaming the good file in the manner described and putting it back does lead to the error when the script tries to access the metadata query's resultAtIndex:0. Basically, the query returns an empty array.

I don't know why the file name causes the metadata query to fail. When the \U00bb is manually changed back to », everything works again — on my system, anyway.


The cures are to correct the problem file's name manually to {125-Bbm}  A.Squared » download-techno.com - Third Eye (Original Mix) » download-techno.com.mp3 (its metadata are OK) and never to use the mdls script again but the ASObjC one.

Last edited by Nigel Garvey (2017-05-03 06:47:16 am)


NG

Offline

 

#79 2017-05-03 07:21:31 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3201

Re: Applescript to read mp3 metatags and sort file into folder

OK. I didn't understood the situation this way.
Described this way, there is no problem.
I will wait for confirmation from the asker before cleaning the script.
In fact I will be unable to do that before 2017/05/12.


Yvan KOENIG running Sierra 10.12.4 in French (VALLAURIS, France) mercredi 3 mai 2017 14:21:24

Offline

 

#80 2017-05-03 08:10:00 am

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2717
Website

Re: Applescript to read mp3 metatags and sort file into folder

If you're not afraid of the beautiful Python language you could consider yourself installing the mutagen python module. Here I posted how to use it in AppleScript.

Offline

 

#81 2017-05-08 08:27:44 am

squigee90
Member
Registered: 2017-03-26
Posts: 26

Re: Applescript to read mp3 metatags and sort file into folder

ok now that its clear that the original mdls shell script was the root cause, from NOW on I will use the new script.

Script from #53 can be re-edited.

Thanks  alot Matt

Offline

 

#82 2017-05-11 01:58:00 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 3201

Re: Applescript to read mp3 metatags and sort file into folder

The script in message #53 is now cleaned.


Yvan KOENIG running Sierra 10.12.4 in French (VALLAURIS, France) jeudi 11 mai 2017 20:57:56

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)