Delete Ressource Fork files on FAT32 Volumes


I just purchased a tiny little USB MP3-player running with an SD-Card. In the Internet I found a great Script to copy playlists directly from within iTunes to any folders or Volumes. Great!

Unfortunately the SD Card is formatted with FAT32 and so the Ressource fork of every Music File is moved into a seperate file starting with “._nnn”. There is also the “.DS_Store” file on the volume. These files cause some errors on my Player and he sometimes crashes. When I delete the files with my PC from the card everything runs fine.

I have attached the whole Script. Who is able to amend a line of AppleScript code to delete these files after the copy procedure has finished?

I have just started with AppleScript (I am familiar with several computer languages), but this issue seems to be not so easy because I couldn’t find an idea of how this could be done (shell script? loop? just a single ‘delete’???)!

Thanks very much in advance!


"Put This Where I Want It" v1.2  for iTunes
written by Doug Adams

Get more free AppleScripts and info on writing your own
at Doug's AppleScripts for iTunes

global tc, plural
tell application "iTunes"
	if selection is not {} then
		set sel to a reference to selection
		tell me to pluralize(count sel)
		set choose_folder_prompt to ("Select a folder to copy the selected track" & plural & " to...")
		set new_site to (choose folder with prompt choose_folder_prompt)
		if new_site is not false then
			set tc to 0
			with timeout of 30000 seconds
				repeat with f in sel
					if f's class is file track then
						set fpath to (get f's location)
						tell me to move_it(fpath, new_site)
					end if -- skip if incorrect type of track
				end repeat
			end timeout
			tell me to pluralize(tc)
			display dialog ("Done!" & return & return & ¬
				(tc as string) & " track" & plural & " of " & (count of sel) as string) & " selected were copied to folder:" & return & ¬
				((get characters 1 thru -2 of (new_site as string)) as string) buttons "Thanks" default button 1 with icon 1
		end if -- cancel from choose folder
		display dialog "Nothing has been selected." buttons {"Cancel"} default button 1 with icon 0
	end if -- no selection
end tell

to move_it(fpath, new_site)
	tell application "Finder"
			duplicate file fpath to folder new_site with replacing
			set tc to tc + 1
		on error eM number eN
			display dialog "Error " & eN & return & eM with icon 2
		end try
	end tell
end move_it

to pluralize(X)
	set plural to "s"
	if X is 1 then set plural to ""
	return plural
end pluralize


Hmmm… When you introduce the thing in your USB port, it is as a regular disk, true?
Then, this one-line should do the job:

tell application "Finder" to delete (every file of entire contents of alias "DISKNAME:" whose name does not end with ".mp3")

Will this work?

[b][color=darkblue]Hi unknown,

thanks for your code, but it is not working. I assume that the Finder can’t remove those invisible files without some other commands…

And the code has two other issue: first the SD-Cards I use do have different names (I think this is stored in the variable new_site) of the iTunes Script and secondly the unwanted files have the same names as the music-tracks, just starting with “._”. So I tried to change the code to the following:[/color][/b]

			tell application "Finder" to delete (every file of entire contents of new_site whose name starts with "._")
			tell application "Finder" to delete (every file of entire contents of new_site whose name is ".DS_Store")

[b][color=darkblue]But this is still not working!
I tried to put the code at different positions (after the first ‘end tell’ and also inside the ‘tell application “iTunes”’ just before ‘display dialog …’ but all without success.

Any good ideas from someone out here??[/b][/color]

Yes, the Finder won’t delete invisible files (those beginning with a dot) – sorry :oops:
This should do the job (but test it carefully):

set theDisk to alias "DISKNAME:"

do shell script "find " & quoted form of POSIX path of theDisk & " -name '.*' -delete"

→ delete any file starting with “.”

Thanks for this early christmas present!!

It works great. I will add some code to make it more comfortable and translate it to german.

jj: please send your real name to “” so I can put it in the header of the script as i like to publish this script. With this script Mac-users will be able to use all USB-sticks with MP3 player and all MP3-players with USB connection very comfortable on their Macs.

Tons of thanks …


Oh, no need of credits. It is a very simple shell script you can pick around the web :wink: