Text Encoding in Datei ändern

Ich brauchte auf die Schnelle ein Skript, mit dem sich eine cvs-Datei die von einem Windows-PC stammt (ISO-8859-1) von der Zeichenkodierung so umstricken lässt, dass ein Mac auf Anhieb (meist UTF-8 oder UTF-16) auch die ganzen Sonderzeichen (öüÖ usw.) korrekt darstellt.
Dieses AppleScript Droplet konvertiert mit iconv die Datei also nach UTF-16 und speicher sie im selben Verzeichnis mit vorrangestelltem _ ab.
Code zum markieren einmal anklicken Code im Skript-Editor öffnen

on open these

tell application "Finder"

if (count of these) is 1 then

repeat with this in these

if name of this ends with ".csv" then

set this_x to POSIX path of this

set this_name to name of this

set this_folder_X to POSIX path of ((container of this) as alias)

do shell script "cd " & quoted form of this_folder_X & ";iconv -f ISO-8859-1 -t UTF-16 " & quoted form of this_x & ">_" & quoted form of (this_name) as text

end if

end repeat

end if

end tell

end open

This entry was posted in Useful Snippets and tagged , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CAPTCHA:


− one = 4

Subscribe without commenting

  • Seite übersetzen:


    Paypal for Pizza:




  • Kategorien


  • Letzte Kommentare

    • Niklas: Vielen Vielen Dank! So klappt es!
    • hubi: Servus Niklas, ich habe mir den Quellcode noch einmal angesehen und habe nun unter 10.7.3 einen Weg gefunden...
    • Niklas: Klingt super das Script. Leider bekomm ich immer folgende Fehlermeldung: error “„Mail“ hat einen Fehler...
    • Jürgen: Hallo Hubi, beim Abfragen von Kennworten gibt es noch eine böse Falle: Das Format, in dem security antwortet,...
    • hubi: Am einfachsten Du öffnest im AppleScript-Editor mal das Funktionsverzeichnis (unter Ablage) von iTunes. Ein...