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


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 | # ]