I have 70,000+ .dta files in a folder that I want to convert to .txt files. None of the examples I found of converting from .dta to .csv worked because my file versions are too new (and I don't have STATA to downgrade these files).
I was able to convert a .dta file manually with Notepad++ by just saving it as a .txt file. The .dta files only had numerical values, so no information was lost during the conversion.
Obviously I cannot save-as each file manually (I have 70,000+). Is there any way I could do this in batches?
From your question, it seems you simply wish to rename the files from *.dta
to *.txt
. Assuming that all the files are in a single folder, paste the following code into a batch file, place the batch file into said folder, and run:
FOR /F "tokens=*" %%I IN ('DIR /B "*.dta"') DO RENAME "%%I" "%%~nI.txt"
If there are files in subdirectories, add the /S
switch after DIR /B
Disclaimer: The dta
files I opened in Notepad++ looked like gibberish.