I have been trying to hack a script. I am not an accomplished scripter
and I am in need of a script that will give me the Filename, Artist,
and Track Title saved to a text file. I have put together the
following script but it fails. The following never executes as far as
I can tell....
try
set track_info to this_track's name & tab & this_track's artist & tab &
fix_filename(this_track's location) & return
end try
therefore, there is never any text inserted into the open BBedit
window. In the Event Log the final message is "The variable track_info is not defined.". I think it may have something to do with the fix_filename subroutine. I'm not sure what is going wrong here, can someone help?
Thanks.
=============================================
tell application "BBEdit 6.5"
set d to make new document
set w to window of d
end tell
tell application "iTunes"
if kind of container of view of front window is not library or selection of front browser window is {} then
display dialog "Select some tracks in iTunes first." buttons {"Cancel"} default button 1 with icon 2 giving up after 15
end if
display dialog "Ready to copy filename, song title, and artist to BBedit window." buttons {"Cancel", "Proceed..."} default button 2
set sel to selection of front browser window
set old_fi to fixed indexing
set fixed indexing to true
with timeout of 3000 seconds
repeat with this_track in sel
if class of this_track is file track and this_track's location is not missing value then
try
set track_info to this_track's name & tab & this_track's artist & tab & fix_filename(this_track's location) & return
end try
end if
tell application "BBEdit 6.5"
select insertion point before character 1 of text window 1
set selection of text window w to track_info
end tell
end repeat
end timeout
set fixed indexing to old_fi
try
display dialog "That's All Folks!" buttons {"Thanks"} default button 1 giving up after 4
end try
end tell
to fix_filename(loc)
set theText to text 1 thru -((length of name extension of (info for loc)) + 2) of (last item of my text_to_list(loc as Unicode text, ":"))
display dialog theText
return theText
end fix_filename
on text_to_list(txt, delim)
set saveD to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to {delim}
set theList to every text item of txt
on error errStr number errNum
set AppleScript's text item delimiters to saveD
error errStr number errNum
end try
set AppleScript's text item delimiters to saveD
return (theList)
end text_to_list
========================================
and I am in need of a script that will give me the Filename, Artist,
and Track Title saved to a text file. I have put together the
following script but it fails. The following never executes as far as
I can tell....
try
set track_info to this_track's name & tab & this_track's artist & tab &
fix_filename(this_track's location) & return
end try
therefore, there is never any text inserted into the open BBedit
window. In the Event Log the final message is "The variable track_info is not defined.". I think it may have something to do with the fix_filename subroutine. I'm not sure what is going wrong here, can someone help?
Thanks.
=============================================
tell application "BBEdit 6.5"
set d to make new document
set w to window of d
end tell
tell application "iTunes"
if kind of container of view of front window is not library or selection of front browser window is {} then
display dialog "Select some tracks in iTunes first." buttons {"Cancel"} default button 1 with icon 2 giving up after 15
end if
display dialog "Ready to copy filename, song title, and artist to BBedit window." buttons {"Cancel", "Proceed..."} default button 2
set sel to selection of front browser window
set old_fi to fixed indexing
set fixed indexing to true
with timeout of 3000 seconds
repeat with this_track in sel
if class of this_track is file track and this_track's location is not missing value then
try
set track_info to this_track's name & tab & this_track's artist & tab & fix_filename(this_track's location) & return
end try
end if
tell application "BBEdit 6.5"
select insertion point before character 1 of text window 1
set selection of text window w to track_info
end tell
end repeat
end timeout
set fixed indexing to old_fi
try
display dialog "That's All Folks!" buttons {"Thanks"} default button 1 giving up after 4
end try
end tell
to fix_filename(loc)
set theText to text 1 thru -((length of name extension of (info for loc)) + 2) of (last item of my text_to_list(loc as Unicode text, ":"))
display dialog theText
return theText
end fix_filename
on text_to_list(txt, delim)
set saveD to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to {delim}
set theList to every text item of txt
on error errStr number errNum
set AppleScript's text item delimiters to saveD
error errStr number errNum
end try
set AppleScript's text item delimiters to saveD
return (theList)
end text_to_list
========================================