Jump to content

Recommended Posts

Hi,

 

I am trying to achieve something quite simple, but can't do it. I want a workflow which gzips all selected files in the Finder in an archive each.

 

So I created a hotkey, and a Terminal command with gzip - but to no avail. Just nothing happens, no error, nothing.

 

Any ideas to get me started?

 

Thanks in advance,

J

Link to comment

Hi,

 

I am trying to achieve something quite simple, but can't do it. I want a workflow which gzips all selected files in the Finder in an archive each.

 

So I created a hotkey, and a Terminal command with gzip - but to no avail. Just nothing happens, no error, nothing.

 

Any ideas to get me started?

 

Thanks in advance,

J

 

Creating a workflow with a file action would be an easy way to accomplish this. Add the File Action item, set properties on it (allow it to accept multiple files), then add a Run Script item. Leave the language as bash and try the following code.

query="{query}"

for element in $query
do
   gzip "$element"
done

That should grab all files that you passed to it and gzip each.

Link to comment

Thank you very much for your quick reply.

Unfortunately, I can't get it to work.

The File Action and Run Script I did set up, but invoking the workflow seems to do nothing.

 

Is it possible that there is a problem with the $-signs in the code?

I am new to bash, but shouldn't  $query and $element have a $-sign?

 

But adding them did not did the trick for me.

Neither did the script

gzip {query}

work for a single file. 

 

It seems so simple, but I am stuck - embarrassing. 

Link to comment

Thank you very much for your quick reply.

Unfortunately, I can't get it to work.

The File Action and Run Script I did set up, but invoking the workflow seems to do nothing.

 

Is it possible that there is a problem with the $-signs in the code?

I am new to bash, but shouldn't  $query and $element have a $-sign?

 

But adding them did not did the trick for me.

Neither did the script

gzip {query}

work for a single file. 

 

It seems so simple, but I am stuck - embarrassing. 

 

My bad, missed a step, I forgot that the for loop would look for items in the string based on a space as a separator. It should be a tab.

query="{query}"

IFS="	"
set $query

for element in $query
do
	gzip "$element"
done

Try that instead

Link to comment

Ah, this was the right tip! The problem was that I had the Escape Spaces option checked. Without it it works!!!

 

Thanks a lot again for your help!

 

Ah stupid me. I actually meant Escape Spaces. Don't know why I said Slashes. I've been working too much lately. I think my brain is fried ha.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...