The Easy Way: Command Line & Data Loader [Tips & Tricks]

Posted August 19th, 2009 in Tips & Tricks and tagged , , , by John Coppedge

At first glance, I thought running the data loader through the command line would be complicated.  Turns out it is actually quite easy.  Essentially all you need to do is create the configuration through the UI and then blast away at the command line:

  1. Create a new folder describing the job; I recommend creating the folder in “C:\Program Files\salesforce.com\Apex Data Loader 12.0\”.  Place your csv file for the job (if required) into this directory.
  2. Start the Data Loader through the UI.  Create and save your field mapping into the above directory.  Configure the action precisely how you want it run in the future from the command line.  Run it (use a 1 record test).  Close the Data Loader.
  3. Copy the “config.properties” file from
    Vista: “C:\Users\%username%\AppData\Roaming\salesforce.com\Apex Data Loader 12.0\”
    XP:  “C:\Documents and Settings\%username%\Application Data\salesforce.com\Apex Data Loader 12.0\”
    to the folder that you created in step #1.
  4. Open a command prompt to “C:\Program Files\salesforce.com\Apex Data Loader 12.0\bin\”.  To run the batch type “process.bat ..\foldername”.  You should see something like this:


A few notes:

  1. I am using version 12; this technique may not work with other versions.
  2. You can use an XML configuration, which allows for greater flexibility.  Here are a few resources if you’d like to go this route:
    Using the Data Loader from the Command Line
    Data Loader Manual
  3. To run the Data Loader on a schedule you’ll need to use a 3rd party application such as windows task scheduler.
  4. Sandbox Orgs through the Data Loader: change server host to https://cs#.salesforce.com, and make sure to append .sandboxname to the end of your username.
  5. When scripting this through a batch file you can append the output to a log file by using output redirection (e.g. “process.bat ..\foldername >> logfile.log”).
[via Force.com Blog, Dev 401 Training Applications Module 3]