Use of RAR archive correctly in subfolders with Hazel

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Issue: I am monitoring a nested set of folders in Hazel for any files which do not start with "sec_" . I then securely RAR any matching files with an embedded script which results in files prefixed sec_ and ending .rar The original file is removed on successful RAR completion by the RAR switches chosen.

So far so good. However, the .rar file is *always* created at the top of the monitored folder set, *not* in the subfolder containing the original target file. I can find no combination of rule/ordering which achieves what I want.

Yes I have read the sticky file in the FAQ about subfolders. The problem may stem from RAR thinking that the source directory is the top folder where the script is invoked, not the subfolder descended to.

Please can you assist - screenshots attached.

thanks
Image
Image
Image
Image
Image
rleaver152
 
Posts: 11
Joined: Sun Apr 30, 2017 3:24 pm

It's always a bad idea to assume the current directory in shell scripts. Either cd to the correct directory or use full paths for any file arguments.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:It's always a bad idea to assume the current directory in shell scripts. Either cd to the correct directory or use full paths for any file arguments.


Thanks but is there anything helpful you can suggest, that I can do with Hazel to give me the result I hope for within what I have shown? I want a generic solution from traversing subdirectories, not hardwiring in a specific directory to cd to or with knowledge of actual paths. Appreciate your insights, thanks.
rleaver152
 
Posts: 11
Joined: Sun Apr 30, 2017 3:24 pm

A full path is passed in via $1. Use the directory part of that.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:A full path is passed in via $1. Use the directory part of that.


Thanks, this is the working solution:

Image

I think it may also help one of the other forum participants who wanted something similar to convert movie files in situ using a shell script
rleaver152
 
Posts: 11
Joined: Sun Apr 30, 2017 3:24 pm


Return to Support