Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

uandme72

macrumors 68020
Original poster
Mar 2, 2015
2,077
684
I want to create an automator quick action to enable creation of tar archives using quick action menus on any selected file or folder. Do I have to use Apple Script or something else?
I am unable to do it. Someone please help.
 

uandme72

macrumors 68020
Original poster
Mar 2, 2015
2,077
684
Screenshot 2022-08-22 at 7.34.15 AM.png


It is giving me this error when 111.xlsx file is tried to be compressed.
 

uandme72

macrumors 68020
Original poster
Mar 2, 2015
2,077
684
I’ve tested the one under “First my version of the TAR script:” and it worked
May I ask why use tar? Selecting files/folders in Finder, then right-click and Compress, creates zip files.
Zip and unzip files and folders on Mac https://support.apple.com/guide/mac-help/zip-and-unzip-files-and-folders-on-mac-mchlp2528/mac

I am using tar for uploading to Apple feedback assistant, for one.
I tried changing script to bash, zsh, but in both cases the script gave errors as per screen shot below.
Kindly help.

Screenshot 2022-08-22 at 7.53.54 PM.png
 

NoBoMac

Moderator
Staff member
Jul 1, 2014
6,302
5,022
If on Monterey, Shortcuts can do this easily.
 

Attachments

  • 810078C0-3CC2-4975-9E32-CF6028BF4816.jpeg
    810078C0-3CC2-4975-9E32-CF6028BF4816.jpeg
    212.9 KB · Views: 95

uandme72

macrumors 68020
Original poster
Mar 2, 2015
2,077
684
If on Monterey, Shortcuts can do this easily.
Shortcuts are more cumbersome than QuickAction in menu showing on right click/ double click against any file or folder.
Kindly guide how to do Quick action to tar.
 
Last edited:

uandme72

macrumors 68020
Original poster
Mar 2, 2015
2,077
684
Here is another one https://superuser.com/a/680400
Tested and working in Big Sur for multiple files/folders. You can change .tgz to .tar
Code:
n=$1
[[ -e $n.tgz ]] && { i=2; n="$1-$i"; }
while [[ -e $n.tgz ]]; do n="${n%-*}-$((i++))"; done
d=${1%/*}
cd -- "$d"
COPYFILE_DISABLE= tar -czf "$n.tar" -- "${@#"$d/"}"
It is also giving me same error message as below- with both bash and zsh shell script options configured.

Screenshot 2022-08-22 at 8.57.28 PM.png
 

NoBoMac

Moderator
Staff member
Jul 1, 2014
6,302
5,022
Shortcuts are more cumbersome than QuickAction in menu showing on right click/ double click against any file or folder.
Kindly guide how to do Quick action to tar.
Shortcuts does do quick actions, just need to code the Shortcut to Quick Action vs prompting for files. And can add Shortcuts to Services menu, menu bar.
 

Attachments

  • quickaction.png
    quickaction.png
    49.3 KB · Views: 88
  • Like
Reactions: uandme72

bogdanw

macrumors 603
Mar 10, 2009
6,145
3,042
Fixed script for Monterey
Code:
n=$1
[[ -e $n.tgz ]] && { i=2; n="$1-$i"; }
while [[ -e $n.tgz ]]; do n="${n%-*}-$((i++))"; done
d=${1%/*}
cd -- "$d"
file_name=$(basename $n)
COPYFILE_DISABLE= tar -czf $file_name.tgz -- "${@#"$d/"}"
 
  • Like
Reactions: splifingate

uandme72

macrumors 68020
Original poster
Mar 2, 2015
2,077
684
Fixed script for Monterey
Code:
n=$1
[[ -e $n.tgz ]] && { i=2; n="$1-$i"; }
while [[ -e $n.tgz ]]; do n="${n%-*}-$((i++))"; done
d=${1%/*}
cd -- "$d"
file_name=$(basename $n)
COPYFILE_DISABLE= tar -czf $file_name.tgz -- "${@#"$d/"}"
Still same error coming:


Screenshot 2022-08-23 at 7.39.31 AM.png
 

bogdanw

macrumors 603
Mar 10, 2009
6,145
3,042
Beats me, this was recorded on M1 12.5.1 (21G83), Run Shell Script version 2.0.3
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.