|
From: Fernando O. <fer...@gm...> - 2010-06-28 21:50:16
|
Thanks a lot Philip, in special taking time for full explanations. You not only gave me an almost cooked fish, you also gave me directions to fish by myself. :-) Your links will be very useful and I will enjoy studying them. Fernando On Mon, Jun 28, 2010 at 14:48, Fmiser <fm...@gm...> wrote: >> Fernando Ossandon wrote: > >> Thanks Philip >> >> I'm under Linux (Ubuntu) >> Your solution worked "almost" perfect at the beginning. I did >> follow your instructions and I also add a couple of lines to >> auto make the destination folder: > > What I usually use is "mkdir -p", which makes the directory if > it's not there, including all parent directories as needed. > This avoids the need for the "if/than" section. > >> My only problem was it only worked fine for >> "non_spaced_file_names". So I did try using "commas" this way: >> for i in ./"*.flac";\ >> but I was only getting a huge concatenated? file. > > Yup. The trick with quotes is to figure out where you want stuff > "protected" > >> Then I did try instead change the above line, add the commas >> to the $i this way: >> >> #!/bin/bash >> if [ ! -d converted/ ]; then >> mkdir converted/ >> fi >> for i in ./*.flac;\ >> do sox -S "$i" -r 44100 -b 16 "converted/$i";\ >> done > > Correct. Bash knows that the spaces are part of the filename in > "for i in *.flac", but it - and SoX - presumes that any > whitespace (space, tab, newline) is a field separator. So when > the bash hands of the list, one item at a time, we need to > insure the next process (SoX in this case) knows it is one item > in spite of the spaces. So that's where the quotes belong. > > Sorry I didn't include that. I _vigorously_ avoid spaces and > other odd characters in filenames so I don't ever really deal > with it. Good job on figuring it out! > > Another point, since you have the shabang (#!/bin/bash), I'm > presuming you are using a script file, not just entering it at a > prompt. If so, you don't need the ";\" at the end of the > lines. That's only necessary for getting it all entered at the > prompt. > >> I have to confess it: it was more "try and fail" than a very >> systematic approach to the solution. >> Still, I want to learn bash. Could you be so nice and >> recommend me a didactic online manual or book? > > There are a lot! Google will find many - but here are my > favorite. > > <http://www.linuxfocus.org/English/September2001/article216.shtml> > > <http://www.notesbit.com/index.php/scripts-unix/a-quick-guide-to-writing-scripts-using-the-bash-shell-linux/> > > <http://tiswww.case.edu/php/chet/bash/bashref.html> > > <http://tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html> > > <http://tldp.org/LDP/abs/html/> > > -- Philip > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > Sox-users mailing list > Sox...@li... > https://lists.sourceforge.net/lists/listinfo/sox-users > |