[clug] Spaces in filenames?

Peter Barker pbarker at barker.dropbear.id.au
Wed Aug 20 11:14:39 EST 2003

On Tue, 19 Aug 2003, Paul Warren wrote:

> I've got a whole bunch of .wav files with spaces in them.  Now it seems
> that linux command line tools don' like spaces.   My usual script to
> encode as ogg's doesn't work:

I can't believe noone provided a perl solution - I saw various shell
tricks and a sed invocation... but really, people!

Old script I have lying around, "quotemeta.pl":
#!/usr/bin/perl -w

while (<>) {
  print quotemeta, "\n";

so: find /misc/media/ogg-peter -type f | sort_random.pl | quotemeta.pl |
xargs xmme -e

Saves the odd piece of punctuation. 'course, you don't need quotemeta in a

find /misc/media/ogg-peter -type f | sort_random.pl | perl -ne
'print quotemeta' | xargs xmme -e


> My question is, How do I turn the spaces to underscores, or
> alternatively, make a script that can work with spaces in filenames!

quotemeta has the advantage of also taking out other potential nasties.

OTOH, the standard print0 and -0 for find and xargs is also a good one to
remember. Just screws up things like the sort_random etc.

> Paul Warren

Peter Barker                          |   N    _--_|\ /---- Barham, Vic
Programmer,Sysadmin,Geek              | W + E /     /\
pbarker at barker.dropbear.id.au         |   S   \_,--?_*<-- Canberra
You need a bigger hammer.             |             v    [35S, 149E]
"They'll need a whole new Orwellian pseudo-crime-name for that... I
 suggest "digital molestation of kittens". -  Jeremi (14640) from Slashdot

More information about the linux mailing list