[wellylug] Odd characters in filenames
Rob Stockley
mowgli at clear.net.nz
Sun Jun 22 10:05:32 NZST 2003
On Sat, 2003-06-21 at 23:26, michael at diaspora.gen.nz wrote:
> Jamie Dobbs writes:
> >I have just noticed that I have series of files that I want to copy from
> >an NFS shared to my PC that have a '%' sign somewhere in their filename
> >(eg apex011a%25.jpg). This appears to be causing some problems and I
> >wonder if there is any easy way to remove the symbol/rename the
> >offending files.
>
> Assuming you're using bash, or at least not a csh type shell, and you
> just want to remove the % from files in the current working directory:
>
> ls *%* | \
> while read file ; \
> do \
> new_file=$(echo $file | sed 's/%//g') ; \
> echo mv $file $new_file ; \
> done
>
> Take out the 'echo' when you're sure it does what you want.
> -- michael.
Nice script :> I've didn't know about the "while read .." construct.
I'll put that one in a safe place.
In the past I've used tar to move stuff from one file system to another.
I've never used it over a network though. Might still work.
tar cf - <files/folders to be moved> | ( cd <destination folder> ; tar
xvf - )
The brackets and semicolon are essential! If you want the transfer to be
done quietly then omit the v option to the second tar.
--
Rob Stockley
Manawatu
New Zealand
An avid user of RedHat Linux
Visit http://www.redhat.com
More information about the wellylug
mailing list