Re: scripting question

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

 



H M Kunzmann <herbert@xxxxxxxxxxxxxxx> writes:

> I've used wget to mirror a site with many subdirectories.
> Unfortunately this site had many spaces in the urls and now I have a
> stack of directories with %20 instead of spaces.
>
> Can I write a script to get all directory names with %20 in the name and
> replace the %20 with spaces ?

Preface these comments with a note that if you have directories with
%20 you may want to do them individually.  I'm not sure what might
happen if you start changing subdir names while a script is running.

That sain One Possible Way (untested) I'd try against the regular files.
Would be a comination tiny script and a find command.

cat mvfl.sh

^^^^^^^^^^^^^^^^^^^^^^^^
#!/bin/sh
mv -i $1 $(echo $1|sed 's/\%20//')
^^^^^^^^^^^^^^^^^^^^^^^^

Use it in a find command:

>From current directory:
   find . -type f -name '*%20*' -ok ./mvfl.sh {} \; 

Using -ok instead of -exec means you'll be asked before each action.
Once you see it doing the job change to `-exec' in place of `-ok'




[Index of Archives]     [Fedora Users]     [Centos Users]     [Kernel Development]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat Phoebe Beta]     [Yosemite Forum]     [Fedora Discussion]     [Gimp]     [Stuff]     [Yosemite News]

  Powered by Linux