Results 1 to 10 of 14
Hi guys. I am writing a script that would take a mp3 file split it into 8.5mb chunks and store it in to a directory with same name as the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 01-27-2005 #1Just Joined!
- Join Date
- Jul 2004
- Posts
- 85
What am I missing in this script?
Hi guys. I am writing a script that would take a mp3 file split it into 8.5mb chunks and store it in to a directory with same name as the source file. Here is the script, as far as I got:
It works fine if you do not acount for the names with spaces, but I need to account for them. I used '\ ' to comment out the spaces. But when it comes time to create a directory it messes up, same is true for the split command.Code:#!/bin/bash #Set the Parameters file=${1//\ /\\ } name=${file%.mp3} #Create Directory For the Output Files mkdir $name #Split the File split -b 8300k -a1 $file $name\ [ #Move Files find -name $name\ [* -exec mv '{}' '$name/{}].mp3' ';'
Here is what I mean, if I give a command:
then evrything is just fine and it creates dir "this is a test"Code:mkdir this\ is\ a\ test
but is I do the this in the script like this:
then the script makes 4 dirs, nameing them "this\\", "is\\", "a\\", and "test"Code:file="this\ is\ a\ test" mkdir $file
Why is that?
- Bogdan
- 01-27-2005 #2Linux Newbie
- Join Date
- Jul 2004
- Location
- WA, USA
- Posts
- 102
In the second example script you did, you used quotation marks. Try it without them.
Robert PeasleeTaking a walk on the wonderful path computers have lain before me
- 01-27-2005 #3Just Joined!
- Join Date
- Jul 2004
- Posts
- 85
Nope that does not work. Any other ideas?
- Bogdan
- 01-27-2005 #4Linux Guru
- Join Date
- Mar 2003
- Location
- Wisconsin
- Posts
- 1,907
Try this
Code:file='this is a test' mkdir $file
Registered Linux user #346571
"All The Dude ever wanted was his rug back" - The Dude
- 01-27-2005 #5Linux Engineer
- Join Date
- Nov 2004
- Location
- Montreal, Canada
- Posts
- 1,267
hey hey x0054
Im glad to see your keeping yourself occupied with those scripts
As jeremy mentionned, try creating a file with space...
Depending on "how this works", it'll tell you if it can work or not...
I remember back in the days, you couldn't create anything with spaces... that could be the problem
EDIT : forgot to mention the solution to this... I never under any occasion create a filename with Spaces... simply replace the " " with "_" fairly easy to do, and very effective on any system\"Meditative mind\'s is like a vast ocean... whatever strikes the surface, the bottom stays calm\" - Dalai Lama
\"Competition ultimatly comes down to one thing... a loser and a winner.\" - Ugo Deschamps
- 01-27-2005 #6
- 01-27-2005 #7Linux Engineer
- Join Date
- Nov 2004
- Location
- Montreal, Canada
- Posts
- 1,267
the "\" before tell the command interpreter not to take the next caracther as a "command option" like in C, to give a path, it would be something alike "c:\\blabla\\somefile.txt"
Originally Posted by qub333 \"Meditative mind\'s is like a vast ocean... whatever strikes the surface, the bottom stays calm\" - Dalai Lama
\"Competition ultimatly comes down to one thing... a loser and a winner.\" - Ugo Deschamps
- 01-27-2005 #8Linux Newbie
- Join Date
- Jul 2004
- Location
- WA, USA
- Posts
- 102
Commonly called escaping characters.
I was looking around online, and never really realized how powerful bash is. I think I need to get my hands a bit more dirty than just using it to run simple commands...
Robert PeasleeTaking a walk on the wonderful path computers have lain before me
- 01-27-2005 #9Linux Guru
- Join Date
- Mar 2003
- Location
- Wisconsin
- Posts
- 1,907
http://www.oreilly.com/catalog/bash2/?CMP=IL7015
You'll be happy you got it!
JeremyRegistered Linux user #346571
"All The Dude ever wanted was his rug back" - The Dude
- 01-27-2005 #10


Reply With Quote
