[X4U] ._*** files on a mp3 player question

Jerry Krinock jerry at ieee.org
Fri Dec 16 11:28:54 PST 2005


on 05/12/16 09:05, Nick Scalise at nickscalise at cox.net wrote:

> There are lots of scripts out on the internet that will hunt down those ._
> files for you.

Well, I couldn't find any of those scripts back when I wrote mine, so here
it is.  It's an AppleScript, but it calls shell scripts to do some of the
work.

It's crude, but it works for me and with some tweaking it might work for
you, or at least you can get some useful tips out of it...........

set playerVolumeLabel to "BOOM"

Log_Start()

set theLogFile to result

tell application "Finder"
    if (disk "BOOM") exists then
        
        -- remove existing files
        tell me to Log_Add("Removing 'Radio' folder on BOOM")
        try
            --do shell script "rm /Volumes/BOOM/Radio/*"
            do shell script "rm -rf /Volumes/BOOM/Radio"
        end try
        
        tell me to Log_Add("Making new 'Radio' folder on BOOM")
        try
            do shell script "mkdir /Volumes/BOOM/Radio"
        end try
        
        (*tell me to Log_Add("Remounting disk 'BOOM'")
        try
            do shell script "diskutil mount /Volumes/BOOM"
            set result to errMsg as string
            tell me to Log_Add(errMsg)
        end try*)
        
        -- write new files
        -- I use the Finder here, because if I use the unix "cp" command,
the files do not play in the correct order.
        tell me to Log_Add("Writing new files to BOOM")

        set theSelection to {} as list -- kludge, may help
        set theSelection to every file of folder "NewHijacks" of folder
"Music" of home

        with timeout of 600 seconds
           log theSelection
            duplicate every item of theSelection to folder "Radio" of disk
"BOOM"
        end timeout
        tell me to Log_Add("Done writing.")
 
        tell me to Log_Add("Removing resource forks")
        -- remove resource forks, because they begin with "._"
        -- The following 3 tries resource forks of files with names
containing up to 2 "dots":
        -- The "try" are used because you may get an error message if there
are no such files.
        try
            do shell script "rm /Volumes/BOOM/Radio/._*"
        end try
        try
            do shell script "rm /Volumes/BOOM/Radio/._*.*"
        end try
        try
            do shell script "rm /Volumes/BOOM/Radio/._*.*.*"
        end try
        
        tell me to Log_Add("Repairing disk 'BOOM'")
        try
            do shell script "diskutil repairvolume /Volumes/BOOM"
        end try
        do shell script "sleep 2"
        
        -- eject player
        tell me to Log_Add("Ejecting BOOM")
        do shell script "diskutil eject /Volumes/BOOM"
        -- if I ever have trouble with that, try this which works better
        -- do shell script "diskutil unmount force /Volumes/BOOM"
        do shell script "sleep 6"
        say "BOOM. eejected"
    else
        tell me to Log_Add("'BOOM' is gone!")
        say "Please connect the portable player and start this application
again"
    end if
end tell

Log_Destroy(theLogFile)

(* Logging Functions  *)
(* In order to log the progress, which is helpful in troubleshooting, I open
a new TextEdit document and write log messages to this TextEdit document.
Note that it is made on the desktop, for convenience.  At the end of the
script, this document is closed and its file deleted from the desktop *)
on Log_Start()
    tell application "Finder"
        make new file at desktop --as alias
        set theLogFile to result
        open theLogFile
    end tell
    return theLogFile
end Log_Start


on Log_Add(newText)
    tell application "TextEdit"
        copy text of first document to oldText
        set newText to oldText & return & return & newText
        set text of first document to newText
        -- The following will only work if TextEdit opens new documents as
rich text by default.
        --tell application "TextEdit" to set size of text of first document
to 20
    end tell
end Log_Add

on Log_Destroy(theLogFile)
    tell application "TextEdit" to close first document
    tell application "Finder" to delete theLogFile
end Log_Destroy




More information about the X4U mailing list