Hi darnel,
Wonderful! Thanks so much for reposting that one. I'll keep the pair tucked
away somewhere safe as I'm sure they will come in very handy again sometime
very soon.
Crumbs, they whiz through only the very most basic functionality of the
component Unix commands at school. You never really get to see them
***embled into anything useful such as the 2 character manipulation scripts
that you've presented. I'm sure I'm going to get a lot out of them once I
get a moment to look up all the respective man pages.
Thanks again for that one Sandy. A super post that lots of people should get
great benefit from.
Regards,
Murray R. Van Luyn.
--
32°02'14.23"S 115°53'21.30"E
http://www.review-a-gadget.com/ http://members.iinet.net.au/~vanluynm/
"darnel" <EMAIL REMOVED> wrote in message
news:EMAIL REMOVED oups.com...
> On Apr 19, 10:53 am, darnel <Sandy.Pittendr...@gmail.com> wrote:
>> On Apr 19, 5:20 pm, "Murray R. Van Luyn." <NOSPAM@NOSPAM> wrote:
>>
>> > I'd really like to see your post on changing characters in filenames
>> > too
>>
>> What if you want to change directory names?
>> What if you want to change file names?
>>
>> Dirs:
>> #!/bin/bash
>> {
>> find $1 -depth -name '*_*' -type d -print |
>> sed 's/./\\&/g' |
>> awk -F/ -vOFS=/ '
>> {
>> old=$0
>> gsub(/_/, "-", $NF)
>> new=$0
>> system("<&3 mv -i -- " old " " new)
>> }'
>>
>> } 3<&0
>>
>> Files:
>> ...use the same script, but change -type d to -type f
>
> So, if you saved the above script as ch_dirs and copied it
> to some server side directory, named perhaps /srv/www/htdocs/testing
> and if testing had a nested directory structure containing files of
> any kind,
> notice the script takes a dollar sign $1 parameter, which is the
> starting
> point directory to operate over. Lets say directory test has a
> subdirectory
> named stuff
>
> do the following:
> backup your stuff directory, so can revert backwards if you
> don't like what happens. Then:
>
> ch_dirs stuff <enter>
> ...and shiver me timbers, away it goes
>