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

[SLUG] Re: recursive %20 to " "



On Sun, Jun 25, 2000 at 10:39:27PM +1000, James Wilkinson wrote:
> On Sun, 25 Jun 2000, Alex S generated:
> 
> >i set up a ftp server and wget (got??) all the files not a prob but it seems to
> >have changed all my spaces to %20 and all @nospam. to %40 or whatever.
> >I am storing all the data on a fat32 partition i had lying around and i was
> >wondering if there is an easy way /script to make all the names back to normal.
> 
> find /dosdir -name '*%20*' -exec mv {} `echo {} | sed 's/\%20/ /'` \;

> I like the first method, but i'm sure someone can find a quicker/shorter
> command (/me thows down the gauntlet ;)

i'm afraid the best (/weirdest) i can do is:

find /dosdir -print | `sed 'h;s/%20/ /g;s/%40/@nospam./g;t c;d;:c x;s/.*/mv & /;G'`

(i can explain the sed further if anyone really wants to know ;)


as much as i hate to admit it, perl's 's///e' is really useful for
this:

find /dosdir -print | \
 perl -ne 'chop;$a=$_;rename $a,$_ if s/%(\d\d)/chr hex $1/ge'

which does general-case "%.." replacement



of course, what alex should have done was:
 smbtar -s hismachine -x hisshare -t hismachine.tar .

-- 
 - Gus
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to slug-request@nospam.slug.org.au with
unsubscribe in the text