MongoDB Bulk import using mongoimport from Windows folder

user3306125 picture user3306125 · Mar 4, 2014 · Viewed 18.1k times · Source

I have a lot of json files in archive and i need to import them into mongo per one operation (i think that it might be in cycle). Have you any ideas about this?

Answer

Sumeet picture Sumeet · Mar 4, 2014

If you are in a Linux/Unix shell you can try

for filename in *; do mongoimport -d mydb -c $filename;  done

If you are on Windows:

FOR %i IN (C:\mongodbData\*.json) DO mongoimport --db dbName --collection colection --type json --file %i