trying to determine the size of all files in a directory
How would I write a script that will determine if all the files in a directory are below say 650mb, and if they are more than 650mb maybe say some sort of error?
Thanks for all help |
try "du -s -k /some/directory/here" and parse the result
|
I'm sorry but I dont even know what parse the results means?
thanks for the help though |
read up on "find", e.g
find /directory -size +650000k will find all files that are over 650mb, then you can use an -exec option (or a thousand other ways) to run a command on each of those files or such like. for details on beginning scripting, read through some of the Rute guide in my signature, and the bash-scripting howto at tldp.org |
this is what I am doing, I am writing a script to burn audio cds, so now it will convert all mp3 files in .wav files normalize them and burn them but I have no clue if there are too many files in the directory to make the cd, so I would like it to check and tell me if there are to many files in that directory...sorry I waited till now to tell you all this.
|
so it's the total size that matters... nice to finally know what we're meant to be solving.
so just check a du output. assuming that there will never be any subdirectories around, this should work. Code:
if [ `/bin/du $1 -s | cut -f1` -lt 650000 ] |
thanks again for the help that should work for me thanks and sorry for not explaining it the right way.
|
sorry for this but everytime I run the script it tells me that there is more than 650mb when there is 606mb in the directory? Thanks for the help and patients
|
All times are GMT -5. The time now is 08:09 AM. |