Skip to content

Instantly share code, notes, and snippets.

@kanghyojun
Created May 6, 2014 16:54
Show Gist options
  • Select an option

  • Save kanghyojun/2b2782ba7400aedc541b to your computer and use it in GitHub Desktop.

Select an option

Save kanghyojun/2b2782ba7400aedc541b to your computer and use it in GitHub Desktop.
on write_to_file(this_data, target_file, append_data) -- (string, file path as string, boolean)
try
set the target_file to the target_file as text
set the open_target_file to ¬
open for access file target_file with write permission
if append_data is false then ¬
set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file
on WriteLog(the_text)
set this_story to the_text
set this_file to (((path to desktop folder) as text) & "deeef")
my write_to_file(this_story, this_file, true)
end WriteLog
tell application "iTunes"
tell library playlist 1
repeat with t in tracks
set n to name of t
set a to album of t
set art to artist of t
set dur to duration of t
set g to genre of t
set p to played count of t
set AppleScript's text item delimiters to "|"
set a to {n, a, art, dur, g, p, "
"}
set theText to a as string
my WriteLog(theText)
end repeat
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment