Unarchive Without Losing Original Files

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

Moderator: Mr_Noodle

Unarchive Without Losing Original Files Tue Feb 25, 2020 1:16 am • by gedwards11
I'm trying to unarchive without using the "open unarchiver" option. I often find that the unarchiver app needs manual intervention to hit "OK" when it encounters an error. This blocks my automated process as any item in the unarchiver queue are now blocked until I log in and hit "OK" to the error message.

The Hazel unarchive is quick and easy. I understand that we don't have an option to save the original files after unarchiving, so I'm using Hazel for a workaround, but I'm stuck.

Situation:
I'm using a private tracker to download shows via Sonarr, which are downloading locally as several rar files. If I unarchive, I can't seed those files as they get deleted. I can't move the files because that would require manual reconnection in my torrent client. Also, I can't copy them to another location and then unarchive, because Sonarr is looking for the movie file in the original location. As such, I'm stuck with using the unarchiver app, but as my issue states above, it often errors out.

Hazel Solution:
If I can copy the files in the same location that they download in (which is a folder with the show's name), then I'll have duplicate rars with the title of those rars ending in a "-1". I can then tell Hazel to unarchive only the archive files which match the name "... -1 ...". Hazel then unzips all the duplicate files, and I get my video file, while also keeping my original rars for seeding. This also lets Sonarr now see the video file where it's looking and it can auto move it to my Plex folders.

I'm Stuck:
I can't figure out a way to do the above idea within Hazel. I've tried using Subfolders, copying, etc, but nothing gets me there. Basically, I need to copy all files in a folder so that the naming convention of the new files ends in "-1". Then I can tell Hazel to only unarchive those files that have "-1" in the title/name.

Any suggestions or ideas?
gedwards11
 
Posts: 4
Joined: Tue Feb 25, 2020 1:00 am

Re: Unarchive Without Losing Original Files Tue Feb 25, 2020 11:18 am • by Mr_Noodle
I'm not clear on why you can't copy the archive and unarchive it elsewhere. Not sure how Sonarr works but it wouldn't know anything about the copies and shouldn't be affected if the original files are there.
Mr_Noodle
Site Admin
 
Posts: 8523
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Unarchive Without Losing Original Files Tue Feb 25, 2020 12:50 pm • by gedwards11
Hi Mr. Noodle. Thank you for the quick response.

Sonarr has an inbuilt series tracker that updates based upon finding the video on your machine. When it sees the video it knows that it can stop looking for that episode and marks it as "downloaded". It's very nice because it tracks all episodes downloaded and lets you see in one glance which ones are missing (because the video is not found on your machine). Sonarr looks at the same location where you download the files to. Sonarr integrates with several torrent clients and the client tells sonar after downloading where to look for the file. In my case, there is no video file for Sonarr to see since I only get downloaded rars. If I unzip the rars, sonarr can see the video, it moves it to my plex folders, and marks it as complete. Without this it will keep trying to find the episode. I would have a flawless system if I could get hazel to work in unarchiving the rars in the same location as the download, but keep my original files.

If there was a way to copy the files elsewhere, unarchive them, and move the movie back to where it came from, that solution would work as well.

Hope that helps. Any creative ideas? I thought about taking the files and sorting them into a subfolder, then copying them to the enclosing folder, then unarchiving the subfolder files, then moving the movie to the enclosing folder. I've tried this, but it never works. Do you know how to make this work?

TV Show Folder
-> Create subfolder (which now contains original files)
-> Copy original files to enclosing folder
Copied Files now in TV Show folder
-> Unarchive files in Subfolder
-> Video now exists in Subfolder
-> Move video to enclosing folder
Video now in TV Show Folder (with seeded files: all rars)
-> Delete Subfolder

This would work for me, but I can't do it in Hazel.
gedwards11
 
Posts: 4
Joined: Tue Feb 25, 2020 1:00 am

Re: Unarchive Without Losing Original Files Wed Feb 26, 2020 10:29 am • by Mr_Noodle
That should be doable. Note when you use the unarchive action, subsequent actions in the same rule will operate on the unarchived results.

Another alternative is to use something like The Unarchiver. It looks like it has a commandline tool which means you can call it from a script.
Mr_Noodle
Site Admin
 
Posts: 8523
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Unarchive Without Losing Original Files Fri Feb 28, 2020 12:55 pm • by gedwards11
Thank you Mr. Noodle.

You say that my ask is doable (in hazel), but I'm not clear on the rules on how to do it. Is this something you can outline for me?

As to your concerns about after Unarchiving, subsequent actions in the same rule will operate on the same files, is totally acceptable. After it does the Unarchive step, my process is done.

Also, as stated in my original post, I have Unarchiver now and am using it, however it errors out intermittently. It stops the entire process and things are blocked until I manually hit "ok" in the unarchiver window to clear the error. This is why I want to use Hazel's Unarchive. It's a very nice and quick solution - if I can duplicate the files.

If possible, let me know the steps in the rules to make the duplicate happen on the archives within the same folder. Please and thank you. Once this is resolved, I'm completely set in my process!
gedwards11
 
Posts: 4
Joined: Tue Feb 25, 2020 1:00 am

For those who may also need this, I was able to solve this using the Unarchiver CLI features. Once I installed CLI for Unarchiver (at this site: https://theunarchiver.com/command-line), I used the following rules to solve:
Dive Into Folder
-If kind is Folder
-Run rules on Folder Contents
Unrar Files (without deleting)
-If kind is Archive
-Run Shell Script - Embedded Script- Value of the script (which uses the command line of Unarchiver): find . -name "*.rar" -execdir unar {} \;

This unzips the rar file (as the movie) and keeps all my original rars for seeding.
gedwards11
 
Posts: 4
Joined: Tue Feb 25, 2020 1:00 am


Return to Support