LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-17-2014, 08:52 AM   #1
moisespedro
Senior Member
 
Registered: Nov 2013
Location: Brazil
Distribution: Slackware
Posts: 1,223

Rep: Reputation: 195Reputation: 195
How to extract all files on a directory and delete all files?


Hi, I download a lot of scene releases and they all come on rar files. Example: downloading an entire season of a tv show. The download is something like this:
Best.TV.Show.Ever.S01 (main directory)
->Best.TV.Show.Ever.S01E01 (sub-directory)
->Best.TV.Show.Ever.S01E02 (sub-directory)
->Best.TV.Show.Ever.S01E03 (sub-directory)
->Best.TV.Show.Ever.S01E04 (sub-directory)
->Best.TV.Show.Ever.S01E05 (sub-directory)
->Best.TV.Show.Ever.S01E06 (sub-directory)

Currently, I navigate through all directories and extract the episodes one by one. Then, I watch the episode and delete the files. Is there an easy way to extract all files and remove them automatically? Extracting one by one manually can be pretty boring and annoying. Thanks and sorry for my bad english.

Last edited by moisespedro; 01-19-2014 at 08:34 AM.
 
Old 01-17-2014, 09:30 AM   #2
xflow7
Member
 
Registered: May 2004
Distribution: Slackware
Posts: 215

Rep: Reputation: 45
So there is one .rar file in each of those sub-directories and you want to extract each of them and then remove the .rar files and sub-directories?

If so, I think something like this should do it (I don't know the syntax for unrar, so I'm guessing on that.):
Code:
$ cd Best.TV.Show.Ever.S01
$ for DIR in `find . -type d`; do
> unrar $DIR/*.rar
> rm $DIR/*.rar
> rmdir $DIR
> done
Dave
 
Old 01-17-2014, 12:01 PM   #3
moisespedro
Senior Member
 
Registered: Nov 2013
Location: Brazil
Distribution: Slackware
Posts: 1,223

Original Poster
Rep: Reputation: 195Reputation: 195
Hmm, here is how they look like
http://i.imgur.com/kcKzT9v.jpg

EDIT: TO extract one has to use "unrar e" on the part 1 archive, then the others will be extracted too.

Last edited by moisespedro; 01-17-2014 at 12:04 PM.
 
Old 01-17-2014, 01:18 PM   #4
xflow7
Member
 
Registered: May 2004
Distribution: Slackware
Posts: 215

Rep: Reputation: 45
OK. In that case, perhaps this:

Code:
$ cd Best.TV.Show.Ever.S01
$ for DIR in `find . -type d`; do
> unrar e $DIR/*01.rar
> rm $DIR/*
> rmdir $DIR
> done
 
Old 01-17-2014, 03:19 PM   #5
moisespedro
Senior Member
 
Registered: Nov 2013
Location: Brazil
Distribution: Slackware
Posts: 1,223

Original Poster
Rep: Reputation: 195Reputation: 195
Won't that exclude all files (including the extracted one?). Actually, won't it exclude the directory too?
 
Old 01-18-2014, 09:55 AM   #6
moisespedro
Senior Member
 
Registered: Nov 2013
Location: Brazil
Distribution: Slackware
Posts: 1,223

Original Poster
Rep: Reputation: 195Reputation: 195
It worked
Is there a way to do it but keep the directories?
 
Old 01-19-2014, 06:42 AM   #7
xflow7
Member
 
Registered: May 2004
Distribution: Slackware
Posts: 215

Rep: Reputation: 45
Hi,

Sorry to not have replied earlier; been traveling.

Glad it worked. To keep the directories, just take out the line that reads
Code:
rmdir $DIR
As for your worry that it would have excluded files, I'm assuming perhaps you were concerned by the "-type d". That option tells the find command to list directories (as opposed to all files). The lines output from the find command are then sequentially assigned to DIR for the execution of the for loop.

Dave

Last edited by xflow7; 01-19-2014 at 06:46 AM.
 
Old 01-19-2014, 08:27 AM   #8
moisespedro
Senior Member
 
Registered: Nov 2013
Location: Brazil
Distribution: Slackware
Posts: 1,223

Original Poster
Rep: Reputation: 195Reputation: 195
Thanks for the help What I was asking is that even if I don't remove the directories all the files are extracted to the main folder (instead of their respective folders). I used to use RARZombie for that (a java applet but, even know it is a java app, I can't get it working - it runs but it doesn't extract).

EDIT: nevermind, just had to replace "e" (to extract to the current folder) for "x" (to keep the full path). Thread is solved, many thanks
EDIT2: Actually it didn't work

Last edited by moisespedro; 01-19-2014 at 08:33 AM.
 
Old 01-19-2014, 07:21 PM   #9
xflow7
Member
 
Registered: May 2004
Distribution: Slackware
Posts: 215

Rep: Reputation: 45
Oh, sorry. I thought you had wanted to delete the sub-folders initially, which is why I wrote it to extract to the main subdirectory.

If you want to end up with the extracted episodes in the sub-folders, then probably this:

Code:
$ cd Best.TV.Show.Ever.S01
$ for DIR in `find . -type d`; do
> cd $DIR
> unrar e *01.rar
> rm *.rar *.nfo *.sfv
> cd ..
> done
I think that should delete the .rar files as well as the .nfo and .sfv files, but leave the extracted files in their respective sub-dirs.

Happy to help.

Dave

Last edited by xflow7; 01-19-2014 at 07:24 PM.
 
Old 01-21-2014, 11:55 AM   #10
moisespedro
Senior Member
 
Registered: Nov 2013
Location: Brazil
Distribution: Slackware
Posts: 1,223

Original Poster
Rep: Reputation: 195Reputation: 195
Thank you very much
 
  


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
Can't delete directory and files Anup D. Linux - Enterprise 3 01-26-2013 09:19 AM
directory does not contain enough space to extract temp files even w/ 15gigs avail? phon_ca Red Hat 5 09-05-2012 01:38 PM
[SOLVED] How to extract tar.gz files to root directory with slackware danthemannewtolinux Slackware 7 02-07-2012 10:37 PM
Delete Files in directory villumanati Linux - General 7 12-30-2008 01:18 PM
How can I delete a directory and its files? OrganicX Linux - General 6 09-01-2002 04:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:13 AM.

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