Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Renaming File Names


From   "Raphael Fraser" <[email protected]>
To   [email protected]
Subject   Re: st: Renaming File Names
Date   Wed, 7 May 2008 09:38:51 -0500

The code worked fine though I adjusted it abit

local myfiles: dir "C:\data\pj\tmru\ccampbell\CRP\actical" files "*.csv"

foreach file of local myfiles {
	local subfile = substr("`file'", 1, 4) + ".csv"
	!rename "`file'" "`subfile'"
}

Raphael


On Tue, May 6, 2008 at 2:45 PM, Friedrich Huebler <[email protected]> wrote:
> Raphael,
>
>  I assume you want to keep the extension.
>
>  local files: dir . files "*.csv"
>  foreach f of local files {
>   local fnew = substr("`f'",1,4)
>   shell ren "`f'" "`fnew'.csv"
>  }
>
>  Friedrich
>
>
>
>  On Tue, May 6, 2008 at 3:07 PM, Raphael Fraser <[email protected]> wrote:
>  > Is it possible to rename the file names below using the first four
>  >  characters in the file name in Stata?
>  >
>  >  018b_crp_13april08.0101.csv
>  >  020b_crp_26apr08.0101.csv
>  >  027b_crp_05april08.0101.csv
>  >  032bb_crp_06april08.0101.csv
>  >
>  >  Raphael
>  *
>  *   For searches and help try:
>  *   http://www.stata.com/support/faqs/res/findit.html
>  *   http://www.stata.com/support/statalist/faq
>  *   http://www.ats.ucla.edu/stat/stata/
>
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index