« home

Guide: Using Dat from the command-line

The dat-next command line tool can be used to share, download, and sync files across many computers via the command line.

Installation

Install via npm:

npm install -g dat-next

You can make sure the install worked by running the dat command. The usage guide should print.

See the installation troubleshooting for tips if the installation failed.

Sharing Files


      dat create
      Dat Archive initialized: /path/to/my-files-to-share
      Link: dat://56c1977328c94c988137c9ff3cbeaab217d765772299840e7be7172b18dbb151

      File import finished!
      Total Size: 50 files (40.5 MB)
      

Now you should have a .dat folder inside my-files-to-share. Once the dat is created, you can start sharing it over the p2p network:


      dat sync
      Syncing Dat Archive: /path/to/my-files-to-share
      Link: dat://56c1977328c94c988137c9ff3cbeaab217d765772299840e7be7172b18dbb151

      Watching files for changes...
      Total Size: 50 files (40.5 MB)

      Looking for connections in Dat Network...
      

The sync command will also watch your directory for changes and share any updated files.

Downloading Files

Once the files are shared somewhere, you can clone them to another location:


      dat clone dat://56c1977328c94c988137c9ff3cbeaab217d765772299840e7be7172b18dbb151 download-folder
      Cloning Dat Archive: /path/to/download-folder
      Link: dat://56c1977328c94c988137c9ff3cbeaab217d765772299840e7be7172b18dbb151

      Metadata: [==================================================>] 100%
      Content:  [====================>------------------------------] 41%
      Total size: 50 files (40.5 MB)

      1 peer on the Dat Network
      Downloading: 5.6 MB/s
      

Downloading Updates

After you clone a Dat archive, you can update the files later:


      dat pull
      Pulling Dat Archive: /path/to/download-folder
      Link: dat://56c1977328c94c988137c9ff3cbeaab217d765772299840e7be7172b18dbb151


      Download Finished!
      Total size: 50 files (40.5 MB)