[CentOS] Fixing filenames with directories with spaces in the names
David G. Miller
dave at davenjudy.orgTue Dec 28 19:12:50 UTC 2010
- Previous message: [CentOS] Fixing filenames with directories with spaces in the names
- Next message: [CentOS] Fixing filenames with directories with spaces in the names
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Craig White <craigwhite at ...> writes: > > 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 > I'm more of a c-shell guy but a "for loop" uses white space (either newline or space) as the delimiter. One of the other responses suggested an alternative loop construct. Alternatively, the find command with the appropriate commands in either a script file or just following a -exec. Something like: find . -type f -exec `new = `echo {} | tr [bad chars] [replace]`; mv {} $new; echo "old: {} new: $new" \; The above needs lots of work but this way you don't have to visit each directory. Cheers, Dave Cheers, Dave
- Previous message: [CentOS] Fixing filenames with directories with spaces in the names
- Next message: [CentOS] Fixing filenames with directories with spaces in the names
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the CentOS mailing list