LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-18-2015, 09:46 PM   #1
steve51184
Member
 
Registered: Dec 2006
Posts: 381

Rep: Reputation: 30
Help using find to extract different types of rar files


Hi my scenario is i have a working directory with several directories within it all containing different types of rar archives like:

Quote:
.part1.rar, .part01.rar, .part001.rar, .rar
So far my command will search the current directory and all directories within that directory looking for .rar archives whilst ignoring any directory called 'Test' and then extract JUST the files with the extensions ext1, ext2, ext3 to the previous directory and it's working quite nicely so far (although I'm sure you can point out several things you could change to improve it or do it the 'correct way' lol)


Code:
find . -iname "*.rar" -not -path "*/Test/*" -exec rar x {} '*.ext1' '*.ext2' '*.ext3' . \;

Problem is like I've said i need to add support for different rar types again:

Quote:
.part1.rar, .part01.rar, .part001.rar, .rar
Now the first three 'part' types aren't a problem and can be easily added to the command but adding .rar will mean it'll extract EVERY file in a (for example) .part1.rar set

How do i add all 4 types of archives to the command without it conflicting?

Note this need to remain 1 line
 
Old 11-19-2015, 03:06 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,623

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
Quote:
.part1.rar, .part01.rar, .part001.rar,
that is a VERY ODD naming ????

normally it is
*.part1.rar, *.part2.rar, *.part3.rar
or
*.rar.001 , *.rar.002 , *.rar.003 ( might need lxsplit)


what are you doing that is creating 4 different types of naming schemes ???
 
Old 11-19-2015, 06:54 PM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by steve51184 View Post
rar archives like:
.part1.rar, .part01.rar, .part001.rar, .rar
(...)
i need to add support for different rar types again:
.part1.rar, .part01.rar, .part001.rar, .rar
The two file type lists are identical. Is that a typo?
Quote:
Originally Posted by steve51184 View Post
Note this need to remain 1 line
Why?
And easy, anyway. If the solution requires several commands, put them onto the same line by separating them with semicolons.
 
Old 11-19-2015, 07:07 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,680

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
There are really only two types, *.partXX.rar are multi volumes archives and *.rar are not. I agree with John VV that the multi volume files are oddly named but we do not know how they were created. If the OP adds the *.rar to the command it will try to unrar the *.partXX.rar that are not the first file in the archive which will fail.

Another possible multi part naming scheme is xyz.rar, xyz.r01 xyx.r02... Not sure that lxsplit will work. I expect the first file in the multi-volume has a file count and combining them into one might cause corruption.

I'm still thinking if a one liner is possible...

Last edited by michaelk; 11-19-2015 at 07:18 PM.
 
Old 11-20-2015, 04:40 AM   #5
steve51184
Member
 
Registered: Dec 2006
Posts: 381

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by John VV View Post
that is a VERY ODD naming ????

normally it is
*.part1.rar, *.part2.rar, *.part3.rar
or
*.rar.001 , *.rar.002 , *.rar.003 ( might need lxsplit)


what are you doing that is creating 4 different types of naming schemes ???
depending on the file size and the split size determines the amount of parts

so a 100mb file with a 25mb per part split will have part1.rar part2.rar etc

if you choose 10mb per split it'll be part01.rar part02.rar etc

and finally if you choose a 1mb split it'll be part001.rar part002.rar etc

and of course the standard .rar for no split
 
Old 11-20-2015, 04:41 AM   #6
steve51184
Member
 
Registered: Dec 2006
Posts: 381

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by berndbausch View Post
The two file type lists are identical. Is that a typo?
no i was just mentioning them twice in my post

Quote:
Originally Posted by berndbausch View Post
Why?
And easy, anyway. If the solution requires several commands, put them onto the same line by separating them with semicolons.
the command is for winscp command feature which only allows 1 line but yes i could use a semicolon
 
Old 11-20-2015, 04:43 AM   #7
steve51184
Member
 
Registered: Dec 2006
Posts: 381

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by michaelk View Post
I'm still thinking if a one liner is possible...
i can use a semicolon if needed
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rar extract files with the original owner, permissions etc. kartoffel Linux - Software 0 09-10-2014 11:44 AM
Combine and extract .rar files villumanati Linux - Newbie 2 09-10-2008 03:59 PM
How to extract rar files in fedora core 6 me4linux Linux - Software 3 04-24-2007 03:09 PM
how to extract RAR files in linux mayankh Linux - Software 3 09-15-2006 04:34 AM
How do I extract miltuple rar files? bankrupt Linux - Newbie 2 12-29-2003 04:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration