Hi everyone,

I wish to rename some excel files on STATA so that only the first 4 characters appear for each file. I ran the following command:

local files: dir "C:\Users\Dell\OneDrive - The University of Nottingham\DISE" files "*.xlsx"
foreach f of local files {
local fnew = substr("`f'",1,4)
!rename "`f'" "`fnew'.xlsx"
}
macro list `fnew'

But when I view the file names using the last command, I see no change in their names. Could anyone please help with this?
Thanks!