|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: RE: combining many data files
On Nov 19, 2008, at 10:16 PM, Mingfeng Lin wrote:
For renaming files (as Kyle mentioned), I just remembered a trick to
rename a large number of files simultaneously on Windows (at least on
XP): select all files you want to rename, then, with cursor pointed at
the first file (all other files still selected), right click and
choose "rename". Then type in something like
file(1).dta
and you'll see all other files renamed into file(2).dta, file(3).dta
etc. But it only works on Windows - for Mac users the extended
function could be the only way out.
Macintosh users have numerous ways to accomplish the objective of
batch renaming files, such as in the above example:
1. Use an Automator action. It is quite easy to link a few Finder
actions and save as a contextual menu plug-in for the Finder that you
can use to rename files in all sorts of ways, including sequential
numbering. Just control-click or right-click on the selected files
and select your saved plug-in. Alternatively, you can download a pre-
made action from, say, <http://automatorworld.com/archives/batch-
rename/>.
2. Use a Unix script. Indeed, one could write a script, save it as
an executable file, and run it from within Stata with the -shell-
command. There are an extremely large number of ways to write such a
script; here is a quick one that works from the bash command line
(i.e., within Terminal.app), similar to the example above:
i=1; for x in *.dta; do cp -p $x file$i.dta; i=$(($i+1)); done
Notice here I have actually copied the files instead of simply
renaming them, so the originals are preserved. To just rename,
replace "cp -p" with "mv".
3. Use a freeware/shareware utility. There are at least a dozen;
here are a few:
<http://www.manytricks.com/namemangler/>
<http://www.mrrsoftware.com/MRRSoftware/NameChanger.html>
<http://software.christopherdrum.com/filewrangler/>
The first two require Mac OS X 10.5; the last will run on version
10.3 and up.
Hope this helps,
Mike
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/