Register FAQ/Rules Forum Spy Search Today's Posts Mark Forums Read

Welcome to the Mac Forums forums. Please read the FAQ if you have questions. Register to participate.

 
Go Back   Mac Forums > Apple Software > Mac OS X Forums > Mac OS X
TouchArcade.com - iPhone Game Reviews and News

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 16, 2007, 12:48 PM   #1
Oats
macrumors regular
 
Join Date: Jan 2003
Location: New York
create zip file without .ds_store files??

I created a zip file using OS X, which is meant to be used cross-platform. I unzipped it in Windows, and I see all these ugly .DS_store and __MACOSX folders. I do not want these hidden files in my ZIP, since they are not hidden or useful for Windows.

Any tools or options I can use to not include these files when creating a ZIP?
Oats is offline   Reply With Quote
Old Mar 16, 2007, 01:17 PM   #2
TheSpaz
macrumors Demi-God
 
Join Date: Jun 2005
Use this Applescript in an Automator workflow and save the plug-in to the Finder to access it in the Finder contextual menu:

Code:
global parentFolder

set selUnixPaths to {}
set tempDir to quoted form of POSIX path of (path to temporary items folder as text)
set itemsUnixPaths to ""

tell application "Finder"
	set finderSelection to selection
	set parentFolder to (container of (item 1 of finderSelection as alias))
	if (length of finderSelection) > 1 then
		repeat with selectedItem in finderSelection
			copy quoted form of ("./" & (name of (selectedItem as alias))) to end of selUnixPaths
		end repeat
		repeat with selectedItem in selUnixPaths
			if itemsUnixPaths = "" then
				set itemsUnixPaths to selectedItem
			else
				set itemsUnixPaths to itemsUnixPaths & " " & selectedItem
			end if
		end repeat
		set archivename to my checkName("Archive.zip")
	else
		set itemsUnixPaths to quoted form of ("./" & name of (item 1 of finderSelection as alias))
		set namewitoutext to my trimext((item 1 of finderSelection) as alias)
		set archivename to my checkName(namewitoutext & ".zip")
	end if
end tell

set shellScript to "cd " & quoted form of (POSIX path of (parentFolder as alias)) & "; zip -b " & tempDir & " -9r '" & archivename & "' " & itemsUnixPaths & " -x *.DS_Store"

with timeout of 60 * 60 seconds
	do shell script shellScript
end timeout

on trimext(myfile)
	tell application "Finder"
		set fileextlenght to count of ((name extension of (myfile)) as text)
		set fileName to name of (myfile)
	end tell
	if fileextlenght > 0 then
		return (items 1 thru -(fileextlenght + 2) of fileName) as string
	else
		return fileName
	end if
end trimext

on checkName(archiveFile)
	tell application "Finder"
		if exists file (((parentFolder as alias) as string) & archiveFile) then
			set fileName to (items 1 thru -5 of archiveFile)
			set x to 2
			repeat while exists file (((parentFolder as alias) as string) & archiveFile)
				set archiveFile to fileName & " " & x & ".zip"
				set x to x + 1
			end repeat
		end if
		return archiveFile
	end tell
end checkName
Edit: You're welcome. I had to figure this out recently so it's great that you asked.
TheSpaz is offline   Reply With Quote
Old Mar 16, 2007, 01:56 PM   #3
Oats
Thread Starter
macrumors regular
 
Join Date: Jan 2003
Location: New York
wow. that Automater script looks like a complete mess! it must have taken a long time. Automater has always been a mystery to me, and I am a programmer, so thats saying something. thanks so much for sharing this!
Oats is offline   Reply With Quote
Old Mar 16, 2007, 02:07 PM   #4
TheSpaz
macrumors Demi-God
 
Join Date: Jun 2005
Quote:
Originally Posted by Oats View Post
wow. that Automater script looks like a complete mess! it must have taken a long time. Automater has always been a mystery to me, and I am a programmer, so thats saying something. thanks so much for sharing this!
Hah. Sorry. I did not write the script but, it took some digging around to find it. And again, you're welcome.
TheSpaz is offline   Reply With Quote
Old Feb 10, 2008, 11:27 PM   #5
indiekiduk
macrumors regular
 
Join Date: Jul 2005
Location: Glasgow, Scotland
You can also use Stuffit in the contextual menu to archive to .zip, and in the settings you can choose to ignore finder files.
indiekiduk is offline   Reply With Quote
Old Jun 19, 2008, 06:47 AM   #6
okaki
macrumors newbie
 
Join Date: Jun 2008
Yemuzip

Or you can simply use "Yemuzip" available for free. You can choose to zip to "windows" style (yeah the first time ever mac sucks). The hidden files mac file system puts everywhere cause so much trouble especially when you just want to do a simple FTP transfer. Just a plain simple file transfer, my web server was ruined.
okaki is offline   Reply With Quote
Old Jun 19, 2008, 07:56 AM   #7
pjrobertson
macrumors 6502a
 
Join Date: Nov 2007
Here's the automator workflow that I use. I'm not sure if it's a duplicate of TheSpaz's

http://mikepiontek.com/software/mac/...n-archive.html
__________________
Macbook C2D - late '07: 2.2GHz, 4GB RAM, 120GB HD, Intel GMA X3100
Running latest Mac OS 10.6.x update
pjrobertson is offline   Reply With Quote
Old Jun 19, 2008, 12:52 PM   #8
SC68Cal
macrumors 68000
 
Join Date: Feb 2006
Why take sixty lines to do one simple command?

Code:
find ~ -name \.DS_Store -print0 | xargs -0 rm
SC68Cal is offline   Reply With Quote
Old Jun 19, 2008, 01:45 PM   #9
mnkeybsness
macrumors 68030
 
mnkeybsness's Avatar
 
Join Date: Jun 2001
Location: Moneyapolis, Minnesota
Send a message via AIM to mnkeybsness
I use the Terminal...

Code:
cd [directory]
zip -r [filename].zip *
Where directory is the directory you want to zip and filename is what you want the zip to be called. This will create the zip file inside of that folder that you just zipped.
__________________
Scribbls - a collaborative drawing community designed to combine drawings into outcomes—no talent required.
mnkeybsness is offline   Reply With Quote
Old Sep 17, 2008, 11:26 PM   #10
fulmar2
macrumors newbie
 
Join Date: Jun 2008
Simple Utility

Why use the terminal when you can use the finder?
Here is a simple drag-and-drop application that will
give you the zip files without the DS_Store and
__MACOSX
.
fulmar2 is offline   Reply With Quote
Old Sep 19, 2008, 04:01 AM   #11
okaki
macrumors newbie
 
Join Date: Jun 2008
Yemuzip is for FREE!

But Yemuzip is for FREE!!!


Quote:
Why use the terminal when you can use the finder?
Here is a simple drag-and-drop application that will
give you the zip files without the DS_Store and
__MACOSX.
okaki is offline   Reply With Quote

Reply

Mac Forums > Apple Software > Mac OS X Forums > Mac OS X

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
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
Forum Jump


All times are GMT -5. The time now is 01:46 PM.

Mac News | Mac Rumors | iPhone Game Reviews | iPhone Apps

Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 2002-2010, MacRumors.com, LLC