[CentOS] Fixing filenames with directories with spaces in the names

Tue Dec 28 05:03:49 UTC 2010
Craig White <craigwhite at azapple.com>

Should be simple and perhaps I'm tired but it's not coming to me.

In its simplest form...

for old in `cat "$FILENAME"`;do
  echo "$old"
  dirname "$old"
  new="$(echo $old | sed 's/\*/\-/')"
done

I'm trying to take out some stupid Macintosh things - in this case
filenames with asterisks but I have others like tilde's and probably
others that I haven't come across.

Anyway, $FILENAME has...

/tmp/New Woman In Field/*NEW woman in field.psd
/tmp/New Woman In Field/*NEW woman in field 2.eps
/tmp/New Woman In Field/*NEW woman in field 2.psd

and the echoes are broken with spaces like this (which of course doesn't
work)...

/tmp/New
/tmp
/tmp/New
Woman
.
Woman
In
.
In
Field/*NEW
Field
Field/-NEW
woman
.
woman
in
.
in
field.psd



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.