Closed Afforess closed 7 years ago
Good job. A feature I'd love to see in master.
Personally, I would try and make use of the unrar -l
.
Output of that command is like so:
UNRAR 5.40 beta 2 freeware Copyright (c) 1993-2016 Alexander Roshal
Archive: the.americans.101.720p-dimension.rar
Details: RAR 4, volume
Attributes Size Date Time Name
----------- --------- ---------- ----- ----
-rw-r--r-- 1878965657 2013-01-30 14:56 The.Americans.2013.S01E01.720p.HDTV.X264-DIMENSION.mkv
----------- --------- ---------- ----- ----
1878965657 volume 1 1
It needs some parsing to get both the filename and size. With those in hand you can look for the file/directory in the directory.
According to this PR unrar lb
gives you just the file - https://github.com/arfoll/unrarall/pull/34
I'd check size because unrarall
may have been interrupted mid extraction (I can't remember if it cleans up in that case).
Your solution has an advantage in that if the file has been moved elsewhere post-extraction then you won't process it again. Combined with a force option you could simply ignore those files. Edit: You already thought of that.
However the disadvantage is like you said. Dotfiles on the file system.
Closing in favor of #40.
I'm not convinced my implementation is the best way to do this, but I didn't see any way to check if the file inside a rar was already extracted with the unrar tool. This seems hard to check for as well with multipart archives.
I decided check for an existing .unrar file which this script creates... which is not ideal (polluting filesystems with dotfiles is a pet peeve of mine). I considered just keeping one file with a list of all the rar archives in the script location, but that's less portable (if you copy/move directories, that will think the file is no longer extracted. At least with dotfiles, they will move with any directory rename).
Thoughts? Suggestions? I'm certain this could be improved.