Hi,
I would like to automate the process of determining the maximum file size among files located in a folder. A code that would work if the size of a file was stored somewhere after use of the "ls" command, say in r(size), would be:
clear
local test = "C:/Users/Stata/Test"
cd `test'
local max = 0
local filelist: dir "." files "*.dta"
foreach file in `filelist' {
ls `file'
local size = r(size)
if `size'>`max'{
local max = `size'
}
}
di `max'
Looking forward to your hints and suggestions.
Thank you!
Max
I would like to automate the process of determining the maximum file size among files located in a folder. A code that would work if the size of a file was stored somewhere after use of the "ls" command, say in r(size), would be:
clear
local test = "C:/Users/Stata/Test"
cd `test'
local max = 0
local filelist: dir "." files "*.dta"
foreach file in `filelist' {
ls `file'
local size = r(size)
if `size'>`max'{
local max = `size'
}
}
di `max'
Looking forward to your hints and suggestions.
Thank you!
Max
Comment