7

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:

image

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]

7 Responses so far.

  1. jon clineNo Gravatar says:

    John, point #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.

    Can’t you use https://test.salesforce.com for this value as well?

    thx.

    jc

  2. jon clineNo Gravatar says:

    now subscribing…

  3. frasuyNo Gravatar says:

    Is the length of time for a job to complete reduced when kicking off the job from the command line vs. the UI?

    I recently began using Informatica’s free data loader. Give that a shot if you are exploring new tools. It’s pretty slick and comprehensive.

  4. jeffdonthemicNo Gravatar says:

    Very nice!!

  5. ForceCertified.comNo Gravatar says:

    @Jon Cline: Yes it looks like test.salesforce.com does work, thanks for the tip!

    @frausy: That does look pretty slick, will definitely give it a go. Here is a link for anyone interested: http://sites.force.com/appexchange/listingDetail?listingId=a0N300000016cUTEAY

  6. VJNo Gravatar says:

    The field mappings can only be saved, when you are doing a Insert/Upsert/Delete operation. NOT when you want to Export from SF

  7. RamNo Gravatar says:

    Hi,

    Is it possible to provide runtime values to the query in process-conf.xml.

Leave a Reply