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:
- 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.
- 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.
- 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. - 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:
- I am using version 12; this technique may not work with other versions.
- 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 - To run the Data Loader on a schedule you’ll need to use a 3rd party application such as windows task scheduler.
- 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.
- 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]