Hi all,
I'm trying to loop through a lot of files and perform different sets of commands for files of different years. I found a previous post about comparing the value of local macros with strings, which made me think I could use "~=" as a comparison. Here is my code (in case of confusion, the file name format is "gen YYYY"):
This returns:
gen 2001.xlsx
gen 2001.xlsx/Data001
gen 2002.xlsx
gen 2002.xlsx/Data001
...
What am I doing wrong? What does ~= do?
Thanks.
I'm trying to loop through a lot of files and perform different sets of commands for files of different years. I found a previous post about comparing the value of local macros with strings, which made me think I could use "~=" as a comparison. Here is my code (in case of confusion, the file name format is "gen YYYY"):
Code:
tempfile building save `building', emptyok local directories: dir . dirs "*" foreach d of local directories { gen temp= "`d'" local files: dir "`d'" files "*.xlsx" foreach f of local files { di "`f'" if "`f'" ~="gen 2014" { di "`f'/`d'" } } }
gen 2001.xlsx
gen 2001.xlsx/Data001
gen 2002.xlsx
gen 2002.xlsx/Data001
...
What am I doing wrong? What does ~= do?
Thanks.
Comment