So, I'm trying to write a line of that will check if there is a directory present, and only try and create a directory if that is false. Found this on the STATA list:
local name test_directory
cd C:\
capture confirm file "./`name'/nul" // check if `name' subdir exists
if _rc { // _rc will be >0 if it doesn't exist
!md "`name'"
}
// my do file
save "C:/`name'/current_data.dta" // optionally add -,replace-
Looks pretty solid overall for my application, but I'm struggling with converting it to Mac compatible syntax.
local name test_directory
cd ~/
capture confirm file "./`name'/*"
// check if `name' subdir exists
if _rc {
mkdir "`name'"
}
Any advice on how to do this right?
Thanks!
Aucun commentaire:
Enregistrer un commentaire