Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6771923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:29:21+00:00 2026-05-26T15:29:21+00:00

Writing a script to help me keep my playlists synchronised between to computers. I

  • 0

Writing a script to help me keep my playlists synchronised between to computers.

I figured I’d do it via applescript.

The first half is the exporting to m3u, which is what I’m getting stuck with.

The code is:

property delimiter_character : " - "

tell application "iTunes"

set this_playlist to playlist "Alternative Mixtape"
set this_name to (the name of this_playlist) as string

set the playlist_count to the count of tracks of this_playlist
set playlist_data to {}
tell this_playlist
    repeat with i from 1 to the count of tracks
        tell track i
            set the end of the playlist_data to {name, delimiter_character, artist, return, location, return}
        end tell
    end repeat
end tell

end tell

set FileName to "Path:To:File.m3u"
set theFile to open for access FileName with write permission
write playlist_data to theFile
close access theFile

Problem is that I get all sorts of “garbled” output:

listlistutxt Hips Of The Yearutxt - utxtMistutxt
alisvvHDD…ÏXËH+Ï›Hips Of The Year.mp3χ»g∏mMp3 hookˇˇˇˇ Bye Bye…Ï<»»gúMϛϋ’.HDD:Music:Mist:Bye Bye:Hips Of The Year.mp3*Hips Of The Year.mp3HDD(/Music/Mist/Bye Bye/Hips Of The Year.mp3

I’ve tried to convert the clipboard to plain text, but I keep getting an error when trying to copy as class UTF8 or as record.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:29:22+00:00Added an answer on May 26, 2026 at 3:29 pm

    m3u is a text file. Your issue is in your code the playlist_data is created as a list. It’s actually a list-of-lists which is even more complicated. So you are writing a list to a file as text… which is how it gets messed up. Try this code. It creates playlist_data as text instead of a list so it writes to the file properly. I made a couple other optimizations too. I hope it helps.

    NOTE: you will have to change the playlistName and filePath to your values.

    property delimiter_character : " - "
    
    set playlistName to "CD 01"
    set filePath to (path to desktop as text) & "cd01.txt"
    
    tell application "iTunes"
        set theTracks to tracks of playlist playlistName
    
        set playlist_data to ""
        repeat with aTrack in theTracks
            tell aTrack
                set trackName to name
                set trackArtist to artist
                set trackLocation to location
            end tell
            set playlist_data to playlist_data & trackName & delimiter_character & trackArtist & return & trackLocation & return & return
        end repeat
    end tell
    
    try
        set theFile to open for access file filePath with write permission
        write playlist_data to theFile
        close access theFile
    on error
        close access file filePath
    end try
    

    One final thing to note. You can write the playlist_data list to a file too. You would have to tell the write statement to write the data as a list in this line “write playlist_data to theFile as list”. You haven’t specified anything in the “as” part of that statement and therefore it does the default behavior of writing the file as text. But you can specify “list” if you wanted. You will notice that you won’t be able to read the file with a text editor if you do this, however the advantage is that you can later read that file “as list” back into an applescript and get the data back in list format. This is not appropriate for your task of writing an m3u file though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need help writing a script downloads data from google insight using c# this is
I am writing a PHP script designed to run an executable file (ffmpeg.exe) via
I'm writing a little python script to help me automate the creation of mysql
I am writing a script to perform tasks between two MySql databases on the
First post, so here goes. I'm writing a script that does intelligent search and
While writing a bash script to help creating polaroid thumbnail using Imagick's convert commmand.
I Need Help in writing script which help me cleaning hash of hashes before
in jsp i am writing java script. Please help me how to do null
I'm writing script in remote.ini The script looks like on 1:start:{ server some.irc.server server
I'm writing a script for Caseware, the accounting software my Company uses, and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.