User Name
Password
AppleNova Forums » Genius Bar »

iPod to iTunes


Register Members List Calendar Search FAQ Posting Guidelines
iPod to iTunes
Thread Tools
omem
Senior Member
 
Join Date: Jan 2005
Location: Portugal
 
2005-06-15, 16:46

I use an Applescript to transfer files from my iPod to my iTunes library and I'm having this strange malfunction. I select all the songs and it transfer all of them except #1! I tried over and over, restarted itunes, etc...even tried with Senuti but with the same result. It just wont copy that mp3.

Has this ever happened to any of you, or do you have a clue of how to solve this?

Thank you

EDIT: nevermind. Senuti did it, but I still wonder why the Applescript couldn't do it with that specific song.

My Apple Gear: iMac G5 1.8GHz 17'' + iPod photo 40GB + iPod shuffle (green) + BlackBook 2.4GHz
Apple Communities: LiveJournal | Last.fm
My sites: Glassjaw.net | HeadAutomatica.net

Last edited by omem : 2005-06-15 at 16:58.
  quote
nassau
Member
 
Join Date: Jul 2004
 
2005-06-15, 19:11

please post that script so the gurus can dissect it
  quote
omem
Senior Member
 
Join Date: Jan 2005
Location: Portugal
 
2005-06-15, 22:58

Here it is.

Code:
(* "Import iPod Audio Files" for iTunes in OS X written by Doug Adams dougadams@mac.com --*** "ProgBar" is an AppleScript Studio application that provides a progress bar. It is available from Spork Software <http://www.sporksoftware.com/> Many thanks to TJ Mahaffey --*** v1.8 December 22, 2004 -- segregated text in display dialogs so localization can occur -- tweaked routine to find XML file (thanks, Sal!) -- fixed problem with locating correct iPod directories on single-partition systems -- fixes error identifying Compilation albums v1.7.1 November 26 2004 - accounts for "." (rather than ":") as time separator v1.7 November 24 2004 - transfers rating from iPod track to newly added iTunes track - account for 12 or 24 hour time formats - better able to work with international localizations - added filter_forward_slash() routine to check strings for '/' character and switch to an underscore to avoid encountering errors in the file copy process (thanks to z4obx0@yahoo.com) v1.6.1 November 5 2004 (not released) - added caution in dialog about selecting iPod tracks in main iTunes window (rather than a separate window) v1.6 November 5 2004 - adds ability to use _optional_ "ProgBar" application to display import progress - updates UNIX "find" command to add modification date as a parameter - accounts for Unknown Artist, Unknown Album (blank artist and/or album tags), and Compilation tracks - fixed potential problem creating new folders in Music folder ("Can't get folder" error) v1.5 October 28 2004 - fixes problem with iTunes 4.7 not recognizing selection properly v1.3 - may 29 04 - fixed problem with locating Music folder on startup drive v1.2 - may 28 04 -- account for 'old-style' Documents/iTunes folder -- more apt to ask for Music folder location if unfound -- use path to special folders in handler v1.0 may 26 04 -- initial release based on "Import Selected iPod Tracks" by John Paul Davis Get more free AppleScripts and info on writing your own at Doug's AppleScripts for iTunes http://www.malcolmadams.com/itunes/ *) -- first item below, meaning Protected, may need to be localized -- usually this file kind is represented as "Protected AAC", but even -- in non-US locatizations, there is generally a space before the "AAC" -- in the file kind name (eg, German: "Geschützte AAC-Audiodatei") -- this is the order of kinds: -- "Protected AAC audio file", "AAC audio file", "MPEG audio file", "Apple Lossless audio file", "WAV audio file", "AIFF audio file" property fileTypes : {" AAC", "AAC", "MPEG", "Lossless", "WAV", "AIFF"} -- the two property lists below are used in the -- check_for_localization() handler; -- they must correspond -- list of localized variations of "Protected" property protected_variants : {"protetto"} -- list of ISO country codes property ISO_list : {"IT"} property fileExtensions : {".m4p", ".m4a", ".mp3", ".m4a", ".wav", ".aif"} -- messages & text (localize if you wish -- don't disrupt returns) == == == == === == === === === = property addenda : " Put imported tracks into new Playlist named...? (Leave blank to skip)" property my_no_button : "No, Just Convert" property error1 : "Please select some tracks on the iPod in the main iTunes browser window." property done1 : "Done!" property thanks1 : "Thanks" property which1 : "Which of these files is " property instruct1 : "Please locate your designated Music folder..." property moment1 : "One moment..." property importing1 : "Importing..." -- names of folders in the Music Folder -- change if necessary property ualb : "Unknown Album" property uart : "Unknown Artist" property comp_artist : "Compilations" -- == == == == == === == == == == == == -- do not change these property movem : false property semiPath : "iTunes:iTunes Music Library.xml" -- == -- *** Global variable ensures that the ProgBar subroutines can understand the fileList. global fileList global pb_exists -- *** -- =============================================================================== -- ok, go.... check_for_ProgBar() check_for_localization() tell application "iTunes" if kind of container of view of front browser window is iPod and selection of front browser window is not {} then set sel to selection of front browser window else display dialog error1 buttons {"Cancel"} ¬ default button 1 with icon 0 end if -- want new tracks in a playlist afterwards? set make_new to text returned of (display dialog addenda default answer "" default button 2) if make_new is not "" then set newPlaylistName to make_new set movem to true end if -- unix path to iPod set theiPod to my unix_fix(my locate_iPods()) -- POSIX + escape bad chars -- used for "find" -- where is your Music folder? set musicFolder to my get_music_folder() --*** set fileList to every item of sel set fileListRef to a reference to fileList set fileCount to (length of sel) if pb_exists then tell application "ProgBar" activate -- ahhh! set title of window "alum_prog_window2" to "Import iPod Audio Files" show window "alum_prog_window2" end tell end if -- *** -- ***Prepare the progress bar. This 'sets up' the progress bar's state. if pb_exists then prep_Progress(fileCount, "alum_prog_window2") of me -- *** -- go get 'em with timeout of 300000 seconds repeat with t from 1 to length of sel -- for each track... -- init set foundFiles to {} -- get info from iPod track tell item t in sel set {siz, art, alb, nom, modt, comp, rat} to {size, my replace_chars(artist as string, ":", "_"), my replace_chars(album as string, ":", "_"), name as string, modification date, compilation, rating} -- make modification date cvs format set modt to my get_modt(modt) -- account for blank Album and/or Artist tag, and Compilation tracks; used later for folders in Music folder if alb is "" then set alb to ualb if art is "" then set art to uart if comp is true then set art to comp_artist -- get extension via kind repeat with k from 1 to count fileTypes if (kind as string) contains (item k of fileTypes) then set ext to item k of fileExtensions exit repeat end if end repeat end tell -- find by size & date last modified set com1 to "find " & theiPod & "iPod_Control/Music -name '*" & ext & "' -type f -size " & siz & "c -newermt '" & modt & "'" set res to (do shell script com1) -- no answer? Try an m4b if res is "" and ext is ".m4p" then set com2 to "find " & theiPod & "iPod_Control/Music -name '*.m4b' -type f -size " & siz & "c -newermt '" & modt & "'" set res to (do shell script com2) end if -- process files found if res is not "" then -- a result from the find -- parse res set foundFiles to my text_to_list(res, return) -- determine correct file, if necessary if length of foundFiles ? 1 then set iPodfile to (choose from list foundFiles with prompt which1 & "\"" & nom & "\":") as string if iPodfile is "false" then error number -128 else set iPodfile to foundFiles as string end if -- name of the file set filename to last item of my text_to_list(iPodfile, "/") -- *** if pb_exists then increment_progbar(t, filename) of me -- *** -- make folder in Music folder, if req tell application "Finder" if not (exists folder art of musicFolder) then ¬ make new folder with properties {name:art} at musicFolder if not (exists folder alb of folder art of musicFolder) then ¬ make new folder with properties {name:alb} at folder art of musicFolder end tell -- copy from iPod to Music folder set theCommand to "cp " & quoted form of iPodfile & " " & quoted form of (POSIX path of musicFolder & art & "/" & alb) do shell script theCommand -- add the file to iTunes set newT to (add ((musicFolder as string) & art & ":" & alb & ":" & filename) as alias) -- transfer rating set newT's rating to rat -- put in new playlist? if movem then if not (exists user playlist newPlaylistName) then set newPlaylist to (make new playlist ¬ with properties {name:newPlaylistName}) else set newPlaylist to user playlist newPlaylistName end if duplicate newT to newPlaylist end if else -- no file found, skip it (for now) end if end repeat -- *** if pb_exists then end_Progress("alum_prog_window2") of me -- *** if pb_exists then tell application "ProgBar" to quit end timeout activate if gave up of (display dialog done1 buttons {thanks1} default button 1 giving up after 15) then return end tell --================= -- this routine is from Apple's "Eject iPod" AppleScript --================= on locate_iPods() set the volumes_directory to "/Volumes/" as POSIX file as alias set the volume_names to list folder volumes_directory without invisibles set mounted_iPods to {} repeat with i from 1 to the count of volume_names try set this_name to item i of volume_names set this_disk to ("/Volumes/" & this_name & "/") as POSIX file as alias set these_items to list folder this_disk if "iPod_Control" is in these_items then set the end of the mounted_iPods to this_disk end if end try end repeat -- check for iPod count if the mounted_iPods is {} then -- try display dialog "iPod is not mounted." buttons {"Cancel"} with icon 0 giving up after 15 on error error number -128 end try else if the (count of the mounted_iPods) is greater than 1 then -- choose iPod set the ipod_names to {} repeat with i from 1 to the count of the mounted_iPods set this_iPod to item i of the mounted_iPods tell application "Finder" set the end of the ipod_names to the name of this_iPod end tell end repeat set this_name to (choose from list ipod_names with prompt "Pick the iPod to use:") as string if this_name is "false" then error number -128 repeat with i from 1 to the count of the ipod_names if item i of the ipod_names is this_name then set this_iPod to item i of the mounted_iPods exit repeat end if end repeat else set this_iPod to item 1 of the mounted_iPods end if return this_iPod end locate_iPods -- thanks to james sorenson on unix_fix(unixpath) set unixpath to (POSIX path of unixpath) set chars to every character of unixpath repeat with i from 1 to length of chars if "!$&\"'*(){[|;<>?~` \\" contains (item i of chars as text) then set item i of chars to ("\\" & (item i of chars as text)) end if end repeat return every item of chars as string end unix_fix on replace_chars(txt, srch, repl) set saveD to AppleScript's text item delimiters set AppleScript's text item delimiters to the srch set the item_list to every text item of txt set AppleScript's text item delimiters to the repl set txt to the item_list as string set AppleScript's text item delimiters to saveD return txt end replace_chars 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 to get_music_folder() set musicFolder to "" try -- get the XML file, which contains the location of the Music folder -- thanks to Sal Soghoian for pointing me in the right direction here set these_paths to do shell script "defaults read com.apple.iapps iTunesRecentDatabases" set the data_file to the text 19 thru ((the offset of "\")" in these_paths) - 1) of these_paths set musicFolder to parse_xml_file((my replace_chars(data_file, "%20", " "))) -- below may not be neccessary! if musicFolder is "" then -- stuff above failed, geez do people still have OS 9-oriented Music folder???? set musicFolder to parse_xml_file((path to documents folder as string) & semiPath) end if end try -- this is probably necessary if musicFolder is "" then -- I still can't find your Music folder set musicFolder to (choose folder with prompt instruct1) else if musicFolder does not start with "Volumes/" then set musicFolder to replace_chars(((get text 1 thru -2 of (path to startup disk as string)) & "/" & musicFolder), "/", ":") as alias else set musicFolder to (last item of text_to_list((POSIX path of musicFolder), "/Volumes:")) as alias end if return musicFolder end get_music_folder to parse_xml_file(thePath) -- this grep routine is lifted and modified from "Wicked Cool Shell Scripts" by Dave Taylor, published by No Starch Press return (do shell script "grep '>Music Folder<' " & (quoted form of thePath) & " | cut -d/ -f5- | cut -d\\< -f1 | sed 's/%20/ /g'") end parse_xml_file to check_for_localization() try set comm to "defaults read \"Apple Global Domain\" AppleLocale" set currentLang to do shell script comm repeat with i from 1 to length of ISO_list if currentLang contains item i of ISO_list then set item 1 of fileTypes to item i of protected_variants end if end repeat end try end check_for_localization to get_modt(modt) -- make cvs-formatted time for 12 or 24 hour time format -- thanks to z4obx0@yahoo.com for the idea set apm to text -2 thru -1 of time string of modt if apm is "PM" then set apm to (text 1 thru -7 of time string of modt) & " pm" else if apm is "AM" then set apm to (text 1 thru -7 of time string of modt) & " am" else set apm to (text 1 thru -4 of time string of modt) log apm end if set apm to my replace_chars(apm, ".", ":") set modt to ((month of modt) & space & (day of modt) & ", " & (year of modt) & space & apm) as string return modt end get_modt to check_for_ProgBar() tell application "Finder" try set pb_exists to exists file (((path to "dlib" from user domain) as string) & "iTunes:Scripts:ProgBar.app") on error set pb_exists to false end try end tell end check_for_ProgBar -- Prepare progress bar subroutine. on prep_Progress(someMaxCount, windowName) tell application "ProgBar" activate tell text field "field_one" of window windowName to set contents to moment1 tell progress indicator "prog_one" of window windowName set content to 0 set uses threaded animation to true start set minimum value to 1 set maximum value to someMaxCount end tell end tell end prep_Progress -- Increment progress bar subroutine. DA added n parameter, the name of the current trak being checked on increment_progbar(item_number, n) tell application "ProgBar" tell text field "field_one" of window "alum_prog_window2" to set contents to importing1 tell progress indicator "prog_one" of window "alum_prog_window2" to set content to item_number tell text field "field_two" of window "alum_prog_window2" to set contents to n end tell end increment_progbar -- End progress bar subroutine. on end_Progress(windowName) tell application "ProgBar" tell progress indicator "prog_one" of window windowName to stop tell progress indicator "prog_one" of window windowName to set content to 0 end tell end end_Progress
  quote
Meltedbutter421
Member
 
Join Date: Jun 2005
Location: New York
Send a message via AIM to Meltedbutter421  
2005-06-18, 09:42

I'm new to macs and the whole applescript thing... if i want to use that code, how do i do that?
  quote
chucker
‽
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2005-07-15, 22:05

Quote:
Originally Posted by Meltedbutter421
I'm new to macs and the whole applescript thing... if i want to use that code, how do i do that?
Open Script Editor, paste it into a new script, and save that (as an application, if you prefer).
  quote
michael gibbs
 
 
2005-07-16, 13:32

Please help!
It used to be Id just Set my iPod in its dock - and, voila, there was my updated iTunes library/contacts/calendar in my iPod. Now, having seriously updated my iTunes library with more good stuff, pop iPod on its dock - a little flurry of activity on the iSync window, it stops as if completed, and there - my iPod is exactly the same as before - nothing changed or downloaded. I tried several times (c.4) - to no avail. Funny thing is, it all acts like its doing what it should - i.e. no problem messages - but nothing is achieved. What am I not doing that I should???
MichaelGibbs
  quote
Posting Rules Navigation
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Post Reply

Forum Jump
Thread Tools
Similar Threads
Thread Thread Starter Forum Replies Last Post
Submissions now being accepted for my first AppleNova article murbot General Discussion 55 2008-11-10 22:53
iPod + iTunes Event 2005 Speculation - new iPod Special Editions? Robo Speculation and Rumors 61 2005-08-13 16:14
iPod Evaluation Messiahtosh Apple Products 14 2005-01-18 13:36
iPod sync - iTunes 4.7 (and iPhoto?) Mac+ Apple Products 7 2004-10-27 14:15
BMW+iPod=Official propellerhead Apple Products 6 2004-06-22 19:07


« Previous Thread | Next Thread »

All times are GMT -5. The time now is 04:12.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2024, AppleNova