panthers built in zip compression

Posted:
in macOS edited January 2014
Is there a key command that will allow multiple files to be selected and zipped individually instead of in one large archive? Or will I have to stay by my system zipping them one by one...

Comments

  • Reply 1 of 9
    mr. memr. me Posts: 3,221member
    Quote:

    Originally posted by climber

    Is there a key command that will allow multiple files to be selected and zipped individually instead of in one large archive? Or will I have to stay by my system zipping them one by one...



    If you want each file zipped separately, then you have to zip them one-by-one. However, it should be possible to write an AppleScript to do the job for you. Automator may be able to write the AppleScript. Look into it.
  • Reply 2 of 9
    lundylundy Posts: 4,466member
    Quote:

    Originally posted by climber

    Is there a key command that will allow multiple files to be selected and zipped individually instead of in one large archive? Or will I have to stay by my system zipping them one by one...



    Do you want the originals to be replaced by the zipped files?
  • Reply 3 of 9
    telomartelomar Posts: 1,804member
    Automator can indeed script archiving.
  • Reply 4 of 9
    climberclimber Posts: 130member
    soory that it has taken me so long to relpy I have been having trouble logging in..no..I don't want to replace the originals..and automator..I am on Panther, my system is pretty old SP 500mhz..and tiger would crawl on it..it looks like one at a time for now. I personnally don't know how to write scripts but if I can find soemone I will ask..



    thanks for the heads up
  • Reply 5 of 9
    lundylundy Posts: 4,466member
    Quote:

    Originally posted by climber

    soory that it has taken me so long to relpy I have been having trouble logging in..no..I don't want to replace the originals..and automator..I am on Panther, my system is pretty old SP 500mhz..and tiger would crawl on it..it looks like one at a time for now. I personnally don't know how to write scripts but if I can find soemone I will ask..



    thanks for the heads up




    It's easy to write an AppleScript in Panther to loop through selected files in the Finder, or pop up a dialog box that would let you choose one or more files, and for each file "foo.bar" selected, it would place in the same directory (or one that you choose) another zipped file "foo.bar.gz". The script would just use the shell command "gzip" in a "do shell script" Applescript command.





    Post back if you want to pursue this. Also, do BSD knowledgeable people know:



    1. To get the suffix ".zip", as best I can tell one has to use the BOMArchiver (that's what the Finder uses) but I can't find this in the man pages. Telling gzip to use the -suffix .zip gives an error.



    2. I have been using gzip but it has no option for creating a separate zipped file - you have to pipe the output to another file. Anybody know a switch that retains the original file(s) that are input to gzip?
  • Reply 6 of 9
    lundylundy Posts: 4,466member
    Here's the script that takes whatever files are selected in the Finder and zips each file leaving the original.



    Code:


    tell application "Finder" to set these_items to the selection



    repeat with i from 1 to the count of these_items

    set this_item to (item i of these_items) as alias

    tell application "Finder"

    set source_path to quoted form of (POSIX path of this_item)

    set dest_path to source_path & ".zip"

    end tell

    do shell script "zip " & dest_path & space & source_path

    end repeat







    Only files, not folders, should be selected before running.



    If one wanted to choose the files from a dialog, that is a trivial change.

  • Reply 7 of 9
    climberclimber Posts: 130member
    I greatly appreciate the help that you are offering Lundy. To be honest I don't even know what to do with the script that you wrote..do I paste it into script editor?Do I compile it..run it record it..save it how where....sorry..real newbie here

    I still have trouble logging in to the forums..I keep egtting a error saying that I violated guidlines..so if I don't reply promptly..that's why



    scott



    thanks again..I will keep playing until I here more
  • Reply 8 of 9
    climberclimber Posts: 130member
    WOW..I actually figured it out..I saved it as a application..run only startup screen..and placed it into the applesript folder..it now shows up with the rest of them in the finder..it is working..just curious..did I save it correctly or is all the saving option necessary?



    thanks again
  • Reply 9 of 9
    lundylundy Posts: 4,466member
    Quote:

    Originally posted by climber

    WOW..I actually figured it out..I saved it as a application..run only startup screen..and placed it into the applesript folder..it now shows up with the rest of them in the finder..it is working..just curious..did I save it correctly or is all the saving option necessary?



    thanks again




    Great. Here's what the saving options do:



    Application: when double-clicked, it runs the script instead of opening it in Script Editor. If you DO want to open it in Script Editor (unless it is run-only, see below), then you drop it onto the Script Editor icon.



    Run-only: script can't be edited. If you want to edit the script to change to another method of choosing the files (say, choosing from the usual "Open" type dialog, or dropping files onto the script icon), then let me know and it will be a trivial change to the script and you can re-copy the code and save the new one in its place.



    Show Startup Screen: Puts up a "Hey I'm about to run; is this OK" type dialog. Most people don't use this but it doesn't hurt anything.



    I did not include error checking for folders being selected, or for nothing being selected. It may crash if that is the case, but no damage should occur.
Sign In or Register to comment.