Fischer-Bayern.de
 FAQFAQ   SuchenSuchen   MitgliederlisteMitgliederliste   BenutzergruppenBenutzergruppen   RegistrierenRegistrieren 
 ProfilProfil   Einloggen, um private Nachrichten zu lesenEinloggen, um private Nachrichten zu lesen   LoginLogin 

Standardize Capitalization of iTunes Tags

 
Dieses Forum ist gesperrt, du kannst keine Beiträge editieren, schreiben oder beantworten.   Dieses Thema ist gesperrt, du kannst keine Beiträge editieren oder beantworten.    Fischer-Bayern.de Foren-Übersicht -> Pool
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen  
Autor Nachricht
Skeeve
•---->
•---->


Anmeldedatum: 20.04.2006
Beiträge: 1067

BeitragVerfasst am: 27.03.2007 - 22:05    Titel: Standardize Capitalization of iTunes Tags Antworten mit Zitat

Update: Kleiner Bugfix bezüglich Umlauten.

Update 2: Kleiner Bugfix da teilweise zuviele Leerzeichen zum Titel hinzugefügt wurden.

Update 3: "Abbrechen" sollte jetzt funktionieren. "beep" am Ende eingebaut

Update 4: setbeep mußte beep sein. Ein "--" zuviel. Dank an dapacerman vom apfeltalk für die Fehlermeldung!

Update 5: Mehr Zeichen werden als, zu Worten gehörig erkannt. Dank an dacaperman.

Ohne Syntax Highlighting wegen eingebettetem Perl Code!

In Englisch, weil ich es gegebenenfalls Doug Adams zur Verfügung stellen werde.

Dies Script standardisiert die Groß- und Kleinschreibung von iTunes Tags.

Ich hoffe, ich finde hier reichlich Bugtester und bekomme entsprechende Rückmeldungen!

Code:
--
-- Standardize Capitalization of Tags
-- written by Skeeve
-- inspired by Doug Adams http://www.malcolmadams.com
--
-- first published 2007.03.27
-- on http://www.fischer-bayern.de
--
-- This script applies the capitalization rules
-- using a perl script.
-- Using this technique should be a bit faster than
-- handling strings with AppleScript. At least I hop so
--
-- Questions & comments to
-- mailto: standardize.question.skeeve et xoxy dot net
--
property fixed_capitalization : "FM USA WDPK OYF’N UR TV MGM DVD ABC CD USSR CA WA NY NYC LP EP VHS UK GB 'Bout 'Cause o' 'n' n' McCartney vs. de feat. Pi-hsien von van I II III IV V VI VII VIII IX X XI XII"

property fixed_mid_words : "a an and at but by for in nor of on or so the to with in"

property other_chars : "_!\"$%&/()=¿?@¡|#¢∞“”[]{}*-+•«»—´'`ºª…:;."

property last_tags : {"Album", "Artist", "Name"}

on run
   set tags to {"Album", "Artist", "Name", "Composer"}
   tell application "iTunes"
      
      if selection of front browser window is not {} then
         set these_tracks to selection of front browser window
         set num to count of these_tracks
         if num is 1 then
            set num to "one track"
         else
            set num to num & " tracks"
         end if
         set which to choose from list tags with title "Capitalize Tags" with prompt "Capitalize " & num & return & return & "Select tags to capitalize." default items last_tags with multiple selections allowed without empty selection allowed
         if which is false then
            error -128
         end if
         set props to {}
         set {oAStid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, tab}
         repeat with this_track in these_tracks
            set track_info to {album, artist, name, composer} of this_track
            copy track_info as text to the end of props
         end repeat
         set AppleScript's text item delimiters to ASCII character 10
         set props to every paragraph of (do shell script "perl <<-''
         use strict;
         use warnings;
         use utf8;
         use encoding 'utf8';
         use open ':utf8';
         use open ':std';
         my @fixed=qw/" & fixed_capitalization & "/;
         my @mid=qw/" & fixed_mid_words & "/;
         my $other_chars=<<'OTHER_CHARS';
         " & other_chars & "
         OTHER_CHARS
         $other_chars=~ tr/\\015\\012//d;
         $other_chars= quotemeta $other_chars;
         my @which= qw/" & (which as string) & "/;
         my @all= qw/" & (tags as string) & "/;
         my %fixed;
         @fixed{map uc,@fixed}=@fixed;
         my $fixed= join '|', keys %fixed;
         $fixed= qr/\\b($fixed)\\b/i;
         my %mid;
         @mid{map uc,@mid}=@mid;
         my $mid= join '|', keys %mid;
         $mid= qr/(?<!^)\\b($mid)\\b/i;
         my %info;
         while (<DATA>) {
            tr/\\015\\012//d;
            @info{@all}= split /\\t/;
            foreach (@info{@which}) {
               $_= join '', map qq'\\u\\L$_', split /([^$other_chars[:alnum:]]+)/o;
               s/$fixed/$fixed{qq'\\U$1'}/g;
               s/$mid/$mid{qq'\\U$1'}/g;
            }
            print join(qq/\\t/, @info{@all}),qq'\\n';
         }
         __DATA__" & (ASCII character 10) & props)
         set AppleScript's text item delimiters to tab
         repeat with i from 1 to count of these_tracks
            set this_track to item i of these_tracks
            set new_props to item i of props
            tell this_track
               set {album, artist, name, composer} to text items of new_props
            end tell
         end repeat
         set AppleScript's text item delimiters to oAStid
         beep
      else
         display alert "Nothing selected"
      end if
   end tell
end run

_________________
"All problems are solved in slightly less than half an hour" (Chumbawamba, "Hey Hey We're The Junkies")
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
Nishaknapp
•--->
•--->


Anmeldedatum: 16.03.2022
Beiträge: 217

BeitragVerfasst am: 13.06.2022 - 09:13    Titel: Antworten mit Zitat

Why not settling on games that is fun and at the same time your earning. Well it'll make suspense because of the game as well but dude just try it and it gave me hope while pandemic is real rn. Winning Baccarat Thru Zigzag Betting System
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
Beiträge der letzten Zeit anzeigen:   
Dieses Forum ist gesperrt, du kannst keine Beiträge editieren, schreiben oder beantworten.   Dieses Thema ist gesperrt, du kannst keine Beiträge editieren oder beantworten.    Fischer-Bayern.de Foren-Übersicht -> Pool Alle Zeiten sind GMT + 2 Stunden
Seite 1 von 1

 
Gehe zu:  
Du kannst keine Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum nicht antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.


Powered by phpBB © 2001, 2002 phpBB Group
Deutsche Übersetzung von phpBB.de


AppleScript für absolute Starter