INTRODUCTION
Hello there,
Like always, I want to put in front that I'm not a script expert. I'm not even a basic coder. I just try to learn, little by little about coding when I have these challenges. Please be through enough for a Dummy!
PRECEDENT
I need to transfer the metadata information of the author of a PDF book to the Author tag in my iTunes library.
(Yes! I got rid of iBooks and got back Books in iTunes)
Recently here in this site, with the help of one of the members I got a script problem solved. Or sort of.
THE PROBLEM
I say sort of, because even when the script will do the task flawlessly if no special character is in the name, the script has a huge limitation: It won't read, write or both, text containing special characters.
EXAMPLE:
Mercé Lamás del Jagüey Nuñez becomes in iTunes Merce\U0301 Lama\U0301s del Jagu\U0308ey Nun\U0303ez-
I appreciate your help to find a solution.
I need to automate this task to properly curate the +4000 PDF books in my iTunes library.
Thank you!
SCRIPT IN DEVELOPMENT
tell application "iTunes"
set sel to the selection
if sel is {} then display dialog "Please select something" buttons {"Cancel"}
repeat with i from 1 to count of sel
set the_track to item i of sel
set the_posix_path to POSIX path of (location of the_track as alias)
set authorfield to paragraph 2 of (do shell script "mdls -name kMDItemAuthors " & quoted form of the_posix_path & "| awk -F\\\" '{print $2'}")
set artist of the_track to (authorfield & "-") as string
end repeat
end tell
GRAPHIC
Best Answer
You can use perl to convert escaped unicode character from ASCII text :
Or python :