Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Remove hidden OS X files from Windows volumes Apps
I've created a free small app called iCleanup to deal with volumes that are being used with Mac OS X as well as Windows -- USB memory keys, for example. The problem with these volumes is that your Mac litters them with hidden files. Windows users can see these files, but they have no use for them.

iCleanup deletes .DS_Store, .Trashes and ._ files from a selected volume and optionally unmounts is. I hope some people will find it useful.

[robg adds: Though we have a few hints on removing .DS_Store files from Unix machines and CDs, we don't have a hint on removing them from Windows machines. I downloaded the app and looked at the AppleScript inside the iCleanup package. It looks relatively benign, but still, it's deleting files, so having a recent backup before running it is a good idea.]
    •    
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[35,808 views]  

Remove hidden OS X files from Windows volumes | 18 comments | Create New Account
Click here to return to the 'Remove hidden OS X files from Windows volumes' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Remove hidden OS X files from Windows volumes
Authored by: trekvogel on Jul 29, '04 10:09:02AM

Nice to see my hint posted here. I did find one bug however. Ejecting a volume will result in a .DS_Store file being created again. I've found a solution and I will post a new version of the program on my site soon.

web.macosx.nl/~timgoeree/icleanup.html



[ Reply to This | # ]
Remove hidden OS X files from Windows volumes
Authored by: jantangring on Jul 29, '04 10:49:53AM
Warning (I think): The script should also escape special characters, as has been previously posted on this group, http://www.macosxhints.com/article.php?story=20011217040113759

---
--

[ Reply to This | # ]

Remove hidden OS X files from Windows volumes
Authored by: cougar718 on Jul 29, '04 04:02:49PM
Hello everyone, No need to escape the characters because the files being searched for do not contain those special characters which need escaping. The script is using find to search the directory chosen by the user for the specific files. The script is safe. However, I do see a problem ...the script assumes you are choosing a Volume or Networked volume...if you choose a folder on that volume ... when the program goes to eject it can't. So the volume never gets ejected or unmounted. Here is the work around I came up with...

Trekvogel I hope you don't mind I modified the script to address the problems and run more efficient. Feel free to use my modified code as your own.

Here are the changes...

The script will now force the user to choose only a Networked volume (Non local volume) and will search the entire volume for the specific files. Opposed to searching certain folders - Reason being is why would you ever want to leave these files on a Operating System that no use for them.

• The beginning of the script has been modified to filter out local volumes.

• The open handler of this script has been modified to allow multiple disks to be processed via Drag-N-Drop

• The script has been broken down into 2 functions for efficiency. searchVolumes(x) and createNetworkList(y)

Take code below, put it into a new script and save it as an application. You are done.


-- Metadata removal application
-- Removes Metadata from Networked volumes
-- Created by TrekVogel (http://web.macosx.nl/~timgoeree/icleanup.html)
-- Modified by Rick alias Cougar (http://home.comcast.net/c0ugar/)

on run
	display dialog "Metadata Removal Tool" buttons {"Ok"} default button 1
	set lst_NetworkDisks to my createNetworkList()
	try
		set a to (choose from list lst_NetworkDisks with prompt "Choose Networked volume you wish to search") as alias
	on error
		return false
	end try
	my searchVolume(a)
end run

on open of folderList
	display dialog "Metadata Removal Tool" buttons {"Ok"} default button 1
	repeat with aFolder in folderList
		my searchVolume(contents of aFolder)
	end repeat
end open

on searchVolume(a)
	set str_VolumeName to a as string
	-- Holds the str_VolumeName needed for successful unmounting of volume
	set str_VolumeName to items 1 thru ((count of str_VolumeName) - 1) of str_VolumeName as string
	set b to "\"" & POSIX path of a & "\""
	set c to "find " & b & " -name .DS_Store -delete"
	try
		do shell script c
	end try
	
	set c to "find " & b & " -name ._\\* -delete"
	try
		do shell script c
	end try
	
	set c to "rm -R " & b & ".Trashes"
	try
		do shell script c with administrator privileges
	end try
	
	display dialog "Do you wish to eject the volume " & str_VolumeName & "?" buttons {"Yes", "No"} default button 1
	set x to result
	
	if button returned of result = "Yes" then
		try
			tell application "Finder" to eject disk str_VolumeName
		end try
	end if
	display dialog "Volume " & str_VolumeName & " successfully cleaned!" buttons "Ok" default button 1
end searchVolume

on createNetworkList()
	-- Build a list of networked / non local volumes (We don't want the user to choose a local volume)
	set lst_NetworkDisks to {}
	tell application "Finder"
		set lst_Disks to disks
		repeat with i from 1 to (count of lst_Disks)
			set currentDisk to item i of lst_Disks
			if ((not local volume of currentDisk) and (name of currentDisk is not "Network") and (name of currentDisk is not "Servers")) then set end of lst_NetworkDisks to name of currentDisk
		end repeat
	end tell
	return lst_NetworkDisks
end createNetworkList

---
Rick alias cougar

[ Reply to This | # ]

Remove hidden OS X files from Windows volumes
Authored by: trekvogel on Jul 29, '04 06:24:21PM

Thank you very much for your tips, I appreciate the feedback I get and I will look at it. I will stay with my original code for now however. Because the script should also work on folders, not only Volumes. That is why you're asked wether you want to eject or not. I do plan to have the script check wether you're cleaning a folder or a volume and act on that knowledge. As said I hope to put a new version on my site asap with some enhancements and mostly fixing the bug that .DS_Store is being created when ejecting.



[ Reply to This | # ]
Remove hidden OS X files from Windows volumes
Authored by: jantangring on Jul 29, '04 09:39:40PM

The file names are ok but the quotes around the volume name will escape neither backquote (`) nor dollar ($).

---
--



[ Reply to This | # ]
Remove hidden OS X files from Windows volumes
Authored by: gidds on Jul 29, '04 10:33:34PM
True. Single quotes would probably do it instead of double ones, but I suspect it's better to use the AppleScript operator quoted form of instead.

---

Andy/

[ Reply to This | # ]

Remove hidden OS X files from Windows volumes
Authored by: jantangring on Jul 30, '04 04:29:18AM

After some experimenting and reading I share Andys recommendation. `quoted form of posix path of a' seems to be the the elegant solution.

Framing with single quotes would not handle correctly path names with single quotes but `quoted form' does

REF: http://developer.apple.com/technotes/tn2002/tn2065.html

---
--



[ Reply to This | # ]
._foo files are resource forks on non-HFS volumes
Authored by: mzs on Jul 29, '04 03:26:18PM
It may not be a good idea to just delete all the ._foo files because these contain the resource fork of the file. This can contain information that you will miss later on the mac. Also, I am weary of deleting anything at all. I have not used DOS/Windows for years now, but I remember the ATTRIB command. With it you could mark files as 'hidden' and this is what you want. This way those files will not appear unless yo do a DIR /A or enable the viewing of hidden and system files in Windows explorer. You should be marking all those files that you do not care about as simply hidden instead of removing them. I recall that there was a collection of tools for when I used linux years ago called mtools. It contained a program called mattrib for this purpose. Maybe there is something similar for MacOS X.

[ Reply to This | # ]
._foo files are resource forks on non-HFS volumes
Authored by: zane on Jul 30, '04 12:45:17AM

I have no choice but to delete the "._foo" files as my SonyEricsson P900's MP3 player determines these as valid MP3's (because they have ".mp3" extensions), tries to play them, and thus crashes.



[ Reply to This | # ]
._foo files are resource forks on non-HFS volumes
Authored by: chris_on_hints on Aug 06, '04 04:04:09AM

Labelling the .Trashes and .DS_Store files as 'hidden' so they dont show up on windows should be the DEFAULT finder behaviour (IMHO).



[ Reply to This | # ]
._foo files are resource forks on non-HFS volumes
Authored by: PeteVerdon on Aug 15, '04 09:56:08AM

Marking as hidden is certainly a more elegant solution - it's the direct equivalent of the . on Unix and OS X. But whether you can do this will depend on the filesystem on the drive. Only FAT (and possibly NTFS, I suppose) have a hidden attribute to be set.

Mind you, since Windows only understands its own formats, perhaps most USB keys are FAT?

Pete



[ Reply to This | # ]
._foo files are resource forks on non-HFS volumes
Authored by: osxmatt on Jan 26, '05 09:37:19PM

Interesting.
I found iCleaner to work just fine. I had an issue where, I tried to copy files from my Mac to my W2K box, and the copy failed due to a file with ._ and then a really long name. The file copied, but then could not be deleted. I found that Cocktail worked to delete the folder of the mapped drive.
Any way to copy files without coping [., ._, .Dstore, ...etc....]???



[ Reply to This | # ]
Remove hidden OS X files from Windows volumes
Authored by: pauljlucas on Jul 29, '04 04:43:07PM

This can be done with a 1-line find command:

find . -name .DS_Store -o -name .Trashes -o -name ._* -exec rm -rf {} \; -prune

You can stick the line into a shell script and take command-line options and such. It's left as an exercise for the reader.

---
- Paul



[ Reply to This | # ]
Remove hidden OS X files from Windows volumes
Authored by: lpangelrob on Jul 29, '04 06:59:48PM

About how much space do these types of files take up over the whole of one drive? Or is this hint just because those files get annoying?

---
-Robert Guico



[ Reply to This | # ]
Remove hidden OS X files from Windows volumes
Authored by: jantangring on Jul 29, '04 09:43:40PM

Annoying, at least. They may show up in playlists on an MP3 player.

---
--



[ Reply to This | # ]
Remove hidden OS X files from Windows volumes
Authored by: zane on Jul 30, '04 12:42:06AM

These files cause errors in my SonyEricsson P900's MP3 player if I don't delete them.

So for me, it's more than just annoying; it breaks/prevents "normal" operation of one of my devices. I haven't yet seen how my video camera handles them.



[ Reply to This | # ]
Remove hidden OS X files from Windows volumes
Authored by: pecosbill on Aug 06, '04 12:54:00PM

Other than what others mentioned about hosing mp3 players, I would expect those files to be benign. They are marked hidden so they should not be seen if Windows is set to hide them. Apple plays by their rules (for the most part).

I do, however, wish that Apple would modify the OS X version of SAMBA to properly replace illegal windows chars when sent to or pulled from Windows. The same should be done with the FAT filesystems.

---
Pecos Bill



[ Reply to This | # ]
How about ICON files?
Authored by: mikerose on Aug 02, '04 11:35:20AM

Any convenient way to deal with the folder icon files? Windows tends to choke on them due to the special character at the end (I believe it's a line break).



[ Reply to This | # ]