ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stephan beal <step...@wanderinghorse.net>
Subject Re: Renaming the directories recursively
Date Wed, 27 Mar 2002 11:11:24 GMT
On Wednesday 27 March 2002 04:32 am, Adam Murdoch wrote:
> > -----Original Message-----
> Unfortunately, to solve your particular problem, I think you will have to
> write your own mapper implementation.  It's not particularaly hard -
> implement FileNameMapper to do the appropriate conversion, compile it up,
> and use <mapper classname=".." /> to use it.

Not to discount that approach, but if you just need this as a one-time fix, 
you could use something like this from the shell:


for d in $(find test -type d | sort -r); do   
	newname=$(echo $d | perl -pe 's/_(\w+)$/$1/;')
	test "$d" = "$newname" && continue
	mv $d $newname
done

Here's what it looks like on my machine:

stephan@cheyenne:~/tmp> rm -fr test; mkdir -p test/_foo/_bar; mkdir -p 
test/_one/_two
stephan@cheyenne:~/tmp> find test
test
test/_foo
test/_foo/_bar
test/_one
test/_one/_two
stephan@cheyenne:~/tmp> for d in $(find test -type d | sort -r); do   
newname=$(echo $d | perl -pe 's/_(\w+)$/$1/;');   test "$d" = "$newname"
&& continue;   mv $d $newname; done
stephan@cheyenne:~/tmp> find test
test
test/foo
test/foo/bar
test/one
test/one/two


-- 
----- stephan
Generic Unix Computer Guy
stephan@einsurance.de - http://www.einsurance.de
Office: +49 (89)  552 92 862 Handy:  +49 (179) 211 97 67
"...control is a degree of inhibition, and a system which is perfectly
inhibited is completely frozen." -- Alan W. Watts

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message