LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices

Reply
 
Search this Thread
Old 01-18-2008, 04:00 PM   #1
PatrickMay16
Member
 
Registered: Apr 2005
Location: London, England.
Distribution: Ubuntu 7.04 "Feisty Fawn"
Posts: 55

Rep: Reputation: 16
bash: sorting a bunch of files into two halfs by size, and other tasks


Hello again.

I'd like to write a script that takes a folder full of wave files, puts them into two groups of half size each (for example, there's a folder with 100MB of wave files so the script halves them into two groups of 50MB), then simultaneously runs a command on the different groups of files.

This way, I can take advantage of my dual core processor even though the current versions of oggenc and lame don't take advantage of multi-core/processor systems.

However, my bash scripting knowledge is very limited. BIG PENIS. Now's your chance! Together, we can write a script that can do this.
So basically, I'm asking for some help and advice, and information, that will help me do this.

Thanks.
 
Old 01-18-2008, 10:50 PM   #2
Daws
Member
 
Registered: May 2006
Location: UK
Distribution: Debian, Linux From Scratch
Posts: 416
Blog Entries: 1

Rep: Reputation: 32
Quote:
However, my bash scripting knowledge is very limited. BIG PENIS. Now's your chance! Together, we can write a script that can do this.
So basically, I'm asking for some help and advice, and information, that will help me do this.
ROFL.

Anyways, I'm not an expert on scripting either, I just thought I'd mention that I have had great difficulty getting bash to do things simultaneously. There is a old thread of mine around here about it, to date I still don't know how to do it. Its fairly easy to get bash to things one after the other very quickly. But when you are encoding, I imagine it may make a difference. You may have to use a proper programming language.

Good luck.
 
Old 01-19-2008, 02:04 AM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,515

Rep: Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855
How about this:
Code:
#Doesn't take size into account, 
#I'm sure it's possible to do that too...
NFILES=$(ls |tee files | wc -l)
GRP1=$(head -$((NFILES/2)) files)
GRP2=$(tail -$((NFILES - NFILES/2)) files)

command $GRP1 &
command $GRP2
 
  


Reply

Tags
bash, lame, script


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
Bash script for sorting and renaming multiple mp3 files by id3 tags simonloach Linux - General 8 02-16-2013 10:07 AM
Bash: sorting by two fields humbletech99 Programming 7 09-25-2007 04:30 PM
Rename a bunch of files auwolf Linux - Newbie 9 10-06-2006 02:55 AM
Sorting files in BASH deleted/ Linux - Newbie 16 01-26-2006 07:03 AM
Sorting by directory size jbg_sm Linux - Newbie 3 04-21-2005 11:32 PM


All times are GMT -5. The time now is 07:10 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration