LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-26-2009, 05:24 PM   #1
Techno Guy
Member
 
Registered: Dec 2008
Posts: 59

Rep: Reputation: 15
How to .rar files that are xMB or bigger only(using shell)


So far i'v found this code:
Code:
find . -size +524288000c
Which will find all the files in the current dir over 500MB big, but I don't know how to integrate that with my current rar script.

Code:
#!/bin/sh 
for FILE in  *.iso *.dmg
do
   DIRNAME=${FILE%.avi}
   DIRNAME=${DIRNAME%.mkv}

   if [ ! -f $DIRNAME ]
   then
 	rar a -m0 -v400M -R toBIG.$DIRNAME.rar $FILE
   else
    echo "$DIRNAME is a file!  Not processing $FILE"
   fi
done

### Finds files bigger then 500MB ###
#find . -size +524288000c
Would love some help please
 
Old 01-26-2009, 05:31 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
I don't really catch what is the aim of this script, anyway to answer to your specific question you don't need to find some files, since you already select the in the for statement
Code:
for FILE in  *.iso *.dmg
so you can just check their size and act accordingly. An easy way is to use the stat command, like this:
Code:
if [ $(stat -c %s $FILE) -gt 512000000 ]
then
  rar a -m0 -v400M -R toBIG.$DIRNAME.rar $FILE
fi
 
Old 01-26-2009, 05:33 PM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
I don't really catch what is the aim of this script, anyway to answer to your specific question you don't need to find some files, since you already select the in the for statement
Code:
for FILE in  *.iso *.dmg
so you can just check their size and act accordingly. An easy way is to use the stat command, like this:
Code:
if [ $(stat -c %s $FILE) -gt 512000000 ]
then
  rar a -m0 -v400M -R toBIG.$DIRNAME.rar $FILE
fi
 
Old 01-27-2009, 09:50 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
For some strange reason this thread is marked as zero-reply. I'm trying to bump it out of the list.

Edit. ok, now the count of answers is correct...!
 
Old 01-28-2009, 12:51 AM   #5
Techno Guy
Member
 
Registered: Dec 2008
Posts: 59

Original Poster
Rep: Reputation: 15
Oh darn where did my reply go (im sure I made one yesterday, oh well ill do it again)

Thanks colucix! that works exactly as I wanted it too, well I needed to change it a bit to fit better but still works fine now thanks again!!
 
Old 01-28-2009, 12:51 AM   #6
Techno Guy
Member
 
Registered: Dec 2008
Posts: 59

Original Poster
Rep: Reputation: 15
Oh darn where did my reply go (im sure I made one yesterday, oh well ill do it again)

Thanks colucix! that works exactly as I wanted it too, well I needed to change it a bit to fit better but still works fine now thanks again!!

Ops, now it made a double post sorry

Last edited by Techno Guy; 01-28-2009 at 12:52 AM.
 
Old 01-28-2009, 01:21 AM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Quote:
Originally Posted by Techno Guy View Post
Oh darn where did my reply go (im sure I made one yesterday, oh well ill do it again)

Thanks colucix! that works exactly as I wanted it too, well I needed to change it a bit to fit better but still works fine now thanks again!!

Ops, now it made a double post sorry
You're welcome! Indeed I saw your reply yesterday, but it looks like this thread has a kind of magic to make posts disappear or posted twice! Anyway, nice to see the solution fit your needs. Bye.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how to deal with .rar files in linux now that rar is no longer part of linux Lleb_KCir Linux - Software 14 11-22-2008 07:01 AM
How do I convert .rar files to .mds files? noimosyni Linux - Software 2 10-03-2008 02:10 PM
question on how to rar multiple files into there own rar file steve51184 Linux - Software 13 10-24-2007 04:23 PM
Can't create files bigger than 0 bytes GameboyHippo Linux - General 1 03-01-2005 08:04 PM
.rar files versus .iso files the difference? dolphans1 Mandriva 14 01-31-2005 09:33 AM


All times are GMT -5. The time now is 12:32 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration