Make archive from applescript

Hi..
I want to run applescript from within Filemaker to make archive of folders (.zip)
Anyone got a script i can modify to make this happend. The paths to folders to compress looks something like this: Fillager_A:2005:9:57912: where 57912 is the folder i want to compress and the delete the folder after compressing.

The folders are holding various files from print jobs

I cant find the command to do the "make archive" in applescript

Thanks for any help

Posted on Sep 13, 2005 5:12 AM

Reply
12 replies

Sep 13, 2005 5:55 AM in response to Karl Sigvart Arnesen

Hi Karl,

This is a handler that I use to zip files or folders:

-- File Zipper
-- Creates zipped file in same folder
-- Pass file/folder path to this handler
-- Returns path to zipped file
on fileZipper(myFile)
if (myFile as text) ends with ":" then
set myDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set myFile to (text items 1 thru -2 of (myFile as text) as text)
set AppleScript's text item delimiters to myDelimiters
end if
set zipFile to (myFile & ".zip") as text
do shell script "/usr/bin/ditto -c -k -rsrc --keepParent " & (quoted form of (POSIX path of myFile)) & " " & (quoted form of (POSIX path of zipFile))
return zipFile
end fileZipper


Best wishes

John M

Sep 13, 2005 6:10 AM in response to John Maisey

wow.. that was fast Thanks a lot
But it was very much new stuff to me here..
if you where to stuff a folder on a server and the path to that folder was:
Fillager_A:2005:9:57916:
Fillager_A is the server, and 2005 is a folder with folder 9 and folder 57916 (where the files are)

how would this look like ?

if you have the time and the would be so kind 🙂

you seem to know this stuff 🙂

Thanks anyway if you don´t have the time

Sep 13, 2005 6:32 AM in response to Karl Sigvart Arnesen

Hi Karl,

You add the fileZipper handler after the main body of your script and call it by fileZipper("path:to:folder:"). The handler does not delete your original folder. You can do this afterwards.

Try this:

-- ... In the body of your script ...
set aFolder to alias "Fillager_A:2005:9:57916:"
-- This folder must exist
set myZippedPath to fileZipper(aFolder)
-- myZippedPath is now the path to the zipped file.
-- ... After the body of your script ...
-- File Zipper
-- Creates zipped file in same folder
-- Pass file/folder path to this handler
-- Returns path to zipped file
on fileZipper(myFile)
if (myFile as text) ends with ":" then
set myDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set myFile to (text items 1 thru -2 of (myFile as text) as text)
set AppleScript's text item delimiters to myDelimiters
end if
set zipFile to (myFile & ".zip") as text
do shell script "/usr/bin/ditto -c -k -rsrc --keepParent " & (quoted form of (POSIX path of myFile)) & " " & (quoted form of (POSIX path of zipFile))
return zipFile
end fileZipper


Best wishes

John M

Sep 13, 2005 9:41 AM in response to John Maisey

It was soo simple to put thi to work from Filemaker 🙂
-------------------------------
set aFolder to cell "full folderpath kopi" of current record
set myZippedPath to fileZipper(aFolder)

on fileZipper(myFile)
if (myFile as text) ends with ":" then
set myDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set myFile to (text items 1 thru -2 of (myFile as text) as text)
set AppleScript's text item delimiters to myDelimiters
end if
set zipFile to (myFile & ".zip") as text
do shell script "/usr/bin/ditto -c -k -rsrc --keepParent " & (quoted form of (POSIX path of myFile)) & " " & (quoted form of (POSIX path of zipFile))
return zipFile
end fileZipper
------------------------------------

But now i need to make a sript that restores this zipped file to the original folder.. (When/if a customer needs a reprint of that job)

Oct 23, 2005 10:53 AM in response to John Maisey

Thanks SO much for posting this, John.
It was exactly what I needed for a project I'm working on. Just stumbled on your post after trying to work up something on my own. Couldn't figure out how to do it via "do shell script" without the preceeding "cd" in the Terminal. (I was trying to use the plain zip command)

Yours works like a dream.
Thank you again!

Oct 24, 2005 5:08 PM in response to John Maisey

Hello

It seems that the handler may be shorten.

on fileZipper(myFile)
if (myFile as text) ends with ":" then set myFile to text 1 thru -2 of (myFile as text)
set zipFile to (myFile & ".zip") as text
do shell script "/usr/bin/ditto -c -k -rsrc --keepParent " & (quoted form of (POSIX path of myFile)) & " " & (quoted form of (POSIX path of zipFile))
return zipFile
end fileZipper

Yvan KOENIG (from FRANCE 25 octobre 2005 1:08:03)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Make archive from applescript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.