Posted on 16 September 2010 by Mitch Abdon
Today I downloaded resources (do-files and datasets) used in the the book Microeconometrics Using Stata, Revised Edition (Cameron and Trivedi, 2009). When I unzipped the file, I found that all the file names in the folder have the prefix “mus”. I want to get rid of these prefixes. Renaming the files one by one seems crude (something that a muggle would do in Harry Potter’s world); somebody must have written a Stata program for this! So I googled using the keywords “stata rename filenames”, and there it was: “FREN: Stata module to batch rename files (Windows only)”.
-fren- (Liu Wei, 2010) renames file names (with specific file extensions) in the current directory. Its syntax is straight forward:
fren file_extension , from(str1) [ to(str2) ]
For example, to get rid of the prefix “mus” from the names of do-files and datasets in the folder, I first installed the program and changed the directory:
ssc install fren
frendta , from(mus)
frendo , from(mus)
And, all those “mus” were gone. Happiness…
To check other commands Liu Wei has written, go to Liu Wei at IDEAS.