[GLLUG] Grep or ls or tail or something

Ben Pfaff blp@cs.stanford.edu
25 Jan 2002 22:58:19 -0800


Mike Szumlinski <szumlins@msu.edu> writes:

> So I'm trying to put together an icecast playlist of a whole lotta songs
> that I have on my system, but it seems that shout's playlist doesn't like
> spaces in file names or diving into directories. Does anyone know a way to
> create a simple text file that takes the recursive contents of a directory
> and prints it in form readable by the playlister?
> 
> i.e.
> 
> Real filename: Picture 1.tiff
> What the playlist needs: Picture\ 1.tiff

Perhaps
        find . -type f -print0 | xargs -0 ls -Q
or maybe
        find . -type f | sed 's/\(.*\)/"\1"/;'
or
        find . -type f | sed 's/\([^./a-zA-Z0-9_-]\)/\\\1/g;'

> I have roughly 3600 files that I'd like to put in, so going back and naming
> them just isn't cool.

Renaming them changing spaces to hyphens is easy, too, if you
have Perl's `rename' utility installed.  Untested:
        find . -type f -print0 | xargs -0 rename 's/\s+/-/g;'