Search code examples
jsonmongodbmongoimport

MongoDB Bulk import using mongoimport from Windows folder


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?


Solution

  • 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