LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to .rar files that are xMB or bigger only(using shell) (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-rar-files-that-are-xmb-or-bigger-only-using-shell-700040/)

Techno Guy 01-26-2009 05:24 PM

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 :)

colucix 01-26-2009 05:31 PM

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


colucix 01-26-2009 05:33 PM

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


colucix 01-27-2009 09:50 AM

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...!

Techno Guy 01-28-2009 12:51 AM

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!!

Techno Guy 01-28-2009 12:51 AM

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 :(

colucix 01-28-2009 01:21 AM

Quote:

Originally Posted by Techno Guy (Post 3423675)
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.


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