Re: Fixing filenames with directories with spaces in the names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Craig White wrote:
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.


I found a nice little Perl script named "cmv" that will do all sorts of file name transformations along the lines you were discussing. You can get it at http://felix.canids.net/plaintext/cmv

Essentially you pass it a Perl regular expression string and a list of files to use the string upon. If you wanted to replace all occurrences whitespace with a single hyphen for the files in a directory:

	cmv 's/\s+/-/g' *

This would find all instances of one or more white space characters and replace them with a single hyphen for every file in the current directory. I've used this for about a year now and it has worked great.

Hope that helps!
--
Jay Leafey - jay.leafey@xxxxxxxxxxxx
Memphis, TN

<<attachment: smime.p7s>>

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux