gnu-arch-users
[Top][All Lists]
Advanced

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

Re: [Gnu-arch-users] Example: renaming files and files references within


From: Aaron Bentley
Subject: Re: [Gnu-arch-users] Example: renaming files and files references within arch
Date: Thu, 09 Sep 2004 11:31:35 -0400
User-agent: Mozilla Thunderbird 0.5 (X11/20040309)

Mark Stosberg wrote:
Hello,

Here's how I solved a need to rename and re-reference a bunch of files
managed by tla. I wanted to rename all my ".tmpl" files to ".html". The files needed to be moved on the file system, and all code references to
".tmpl" updated. Here's how I did it:

 # 1. Find all files named .tmpl and rename them to .html
 for f in `find html_root -name '*.tmpl'`; {
   tla mv $f  `perl -e '($p) = $ARGV[0]; $p =~ 
s/(.*)\/([\w\-]+).tmpl/$1\/$2.html/; print $p' $f` ;
 }
# 2. while protecting the {arch} directory, rename all references in the code from '.tmpl' to '.html'
 chmod -R -w '{arch}'
 grep -Rl '.tmpl' * | xargs perl -pi -e 's/\.tmpl/.html/g'
 chmod -R +w '{arch}'

#################

Any suggestions for easier ways to accomplish these steps (especially the first?

It looks like you're ignoring "tla inventory --source". If you had tmpl files that weren't source, 1 would not work very well. Instead, you should be able to do:

for q in $(tla inventory --source|grep "\.html$"|sed s/\.tmpl$//); do
  tla mv $q.html $q.tmpl
done

And for the second, inventory excludes {arch} by default, so

grep -Rl '.tmpl' $(tla inventory --source) | xargs perl -pi -e 's/\.tmpl/.html/g'

Unless you have non-source files that may include that text.

Oh, and I'd run tla changes --diffs afterward, and make sure that that no undesired changes were introduced.

Aaron
--
Aaron Bentley
Director of Technology
Panometrics, Inc.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]