I am working with a bunch of excel files and wish to re-save them without any spaces in the file name. Have tried to run the following code, however i encountered an error with "type mismatch". I am not sure how to fix this. Please advise.
Below is a picture of the folder and filenames that Stata is reading
Array
Code:
set more off clear local myfiles: dir "C:\Users\Eprifellow\Dropbox (EPRI)\EPRIProject2019UNICEFMontenegro\Deliverables\Part4\SWIS" files "*.xlsx" foreach file of local myfiles { local subfile = substr("`file'"," ", "") !rename "`file'" "`subfile'" }
Below is the error code runs into
Code:
. local myfiles: dir "C:\Users\Eprifellow\Dropbox (EPRI)\EPRIProject2019UNICE > FMontenegro\Deliverables\Part4\SWIS" files "*.xlsx" . . foreach file of local myfiles { 2. local subfile = substr("`file'"," ", "") 3. !rename "`file'" "`subfile'" 4. } - foreach file of local myfiles { - local subfile = substr("`file'"," ", "") = local subfile = substr("1 Number of all users by CSW-DEC-18.xlsx"," ", "") type mismatch !rename "`file'" "`subfile'" } r(109); end of do-file r(109);
0 Response to Remove space from file name
Post a Comment