From: Vahis on 4 Jan 2010 15:09 On 2010-01-04, David Bolt <blacklist-me(a)davjam.org> wrote: > On Monday 04 Jan 2010 18:13, while playing with a tin of spray paint, > Vahis painted this mural: > >> By searching and pecking (the way I type, too), I came to put this >> together: >> >> #!/bin/sh <snip> > #!/bin/bash <snipped and saved> > done > > Regards, > David Bolt > Thanks a lot once again, David :) I definitely need a few hours of sleep now. I'll hit the files tomorrow again. Vahis (dives to hay) -- "Sunrise 9:25am (EET), sunset 3:25pm (EET) at Espoo, FI (6:00 hours daylight)" http://waxborg.servepics.com Linux 2.6.25.20-0.5-default #1 SMP 2009-08-14 01:48:11 +0200 x86_64 10:02pm up 66 days 3:03, 12 users, load average: 0.26, 0.28, 0.27
From: David Bolt on 4 Jan 2010 16:04 On Monday 04 Jan 2010 20:34, while playing with a tin of spray paint, houghi painted this mural: > I would use > find /dir/to/music -type f -name "*.ogg" | \ > ... > > That way you won't run it in the wrong directory by accident. Good point. Regards, David Bolt -- Team Acorn: www.distributed.net OGR-NG @ ~100Mnodes RC5-72 @ ~1Mkeys/s openSUSE 11.0 32b | | openSUSE 11.2 32b | openSUSE 11.0 64b | openSUSE 11.1 64b | openSUSE 11.2 64b | TOS 4.02 | openSUSE 11.1 PPC | RISC OS 4.02 | RISC OS 3.11
From: David Bolt on 4 Jan 2010 17:24 On Monday 04 Jan 2010 21:43, while playing with a tin of spray paint, houghi painted this mural: > David Bolt wrote: >> Good point. > > Guess how I learned that. (Hint: it wasn't from a book.) You're not making me try to remember things are you? Regards, David Bolt -- Team Acorn: www.distributed.net OGR-NG @ ~100Mnodes RC5-72 @ ~1Mkeys/s openSUSE 11.0 32b | | openSUSE 11.2 32b | openSUSE 11.0 64b | openSUSE 11.1 64b | openSUSE 11.2 64b | TOS 4.02 | openSUSE 11.1 PPC | RISC OS 4.02 | RISC OS 3.11
From: Shmuel Metz on 4 Jan 2010 18:16 In <slrnhk4o87.evn.houghi(a)penne.houghi>, on 01/04/2010 at 10:43 PM, houghi <houghi(a)houghi.org.invalid> said: >Guess how I learned that. The same way that I was reminded that "EXEC CMS ERASE" is not equivalent to "ERASE CMS EXEC". It's amazing how quickly you can hit PA1 while muttering vile imprecations. -- Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel> Unsolicited bulk E-mail subject to legal action. I reserve the right to publicly post or ridicule any abusive E-mail. Reply to domain Patriot dot net user shmuel+news to contact me. Do not reply to spamtrap(a)library.lspace.org
From: David Bolt on 5 Jan 2010 15:14 On Tuesday 05 Jan 2010 08:20, while playing with a tin of spray paint, Vahis painted this mural: > #!/bin/sh > #Following three lines commented out to test the line by David Bolt > # > #for x in * ; do mv "$x" `echo -n $x | tr " " "_"`; done > #for x in *.ogg ; do sox $x `echo $x|awk -F . '{print $1 ".mp3"}'`; done > #find ./ -name '*ogg' -exec rm '{}' ';' -print > # > #Here's David's line (this does all the above in one go): > # > for x in *.ogg ; do sox "${x}" "${x%.ogg}.mp3" && rm "${x}" ; done > # > #The line above does the job. > #The next thing is to make it recursive. > .................. > > So what you suggested yesterday is once again a working solution :) I try, or I'm very trying, depending on who you ask. > Your one line does what I was able to do with three :) > > The only thing still missing is recursiveness. I posted a version that does support recursive conversions in the "web development preferences", although I wrote that one in PHP rather than bash script. Here's another version of that script, but one that will work through multiple directories. Again, it's in PHP, and this time it properly capitalises the words in the file name: #!/usr/bin/php <?php /* * this is designed to run as a shell script. don't run it via a web server */ // build an array of paths to convert using either paths passed on the // command line, or create an array containing only the current directory // $paths=array(getcwd()); if($argc>1) // if there's any paths passed $paths=array_slice($argv,1); // replace CWD with them $count=0; foreach($paths as $source_dir) { $files=array(); exec("find '".$source_dir."' -type f -name '*.ogg'",$files); if($files===FALSE) // none found die("Nothing to convert.\n"); // so quit foreach($files as $file) { // skip unreadable files // if(!(is_readable($file))) continue; // change '_' to ' ' and upper-case the initial letter of all the words // $name=ucwords(str_replace("_"," ",basename($file,"ogg"))); // construct the output filename // $output=dirname($file)."/".$name."mp3"; // bit of feedback while doing the conversion // lets the user know the script hasn't crashed // printf("Converting %s\n",$file); // then get sox to do the conversion // passthru("sox '".$file."' '".$output."'",$ret_val); // if sox converts the file successfully // if(!$ret_val) { // unlink($file); // delete the original $count++; } } } // and finally say just how many files were really converted. // die("Converted ".$count." files\n"); ?> > This the 271 files are in 16 subdirectories. > This the directory names have underscores, no spaces like the files. > But also the directories could have spaces at some stage. The above should handle that although you will need to either escape spaces or wrap the paths in quotes. Again, just to be sure it works for you, do a test run with the unlink($file) commented out. Once you're sure it works, remove the '//' from the beginning of the line. Regards, David Bolt -- Team Acorn: www.distributed.net OGR-NG @ ~100Mnodes RC5-72 @ ~1Mkeys/s openSUSE 11.0 32b | | openSUSE 11.2 32b | openSUSE 11.0 64b | openSUSE 11.1 64b | openSUSE 11.2 64b | TOS 4.02 | openSUSE 11.1 PPC | RISC OS 4.02 | RISC OS 3.11
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: Removing USB devices with 11.2/KDE4 Next: Web development preferences |