function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Dynamic file names for Data loader CLI exported data

I would like to export the account data periodically using CLI data loader and generate the export file names dynamically with export time stamps.Eg:- If i am running the export @28-Mar-2016 , file should be "AccountExport28-Mar-2016" .
Hi Naren,

You may consider to rename the file after expoted using batch file.


Thanks myatmyat for the reply.

I tried for it, but i could not do it. Please let me know how to achieve the same.Please share me if you have any snippets.
Hi Naren,

cd D:\Data\Salesforce\DataFiles
ren csvfile.csv csvfile_%date:~-4,4%%date:~-7,2%%date:~-10,2%.csv

This is sample command how to rename your csv file. You may change the command as your format.

Menachem M ShanowitzMenachem M Shanowitz
The output file name is set with the property which can be set dynamically in the command line. 

The command-line version runs with whatever properties you have in your file, but you can also pass paramters at runtime as arguments to the program.

For example, the following command sets the operation to insert regardless of what settings are contained in the file:
java -cp target/dataloader-xx.0-uber.jar -Dsalesforce.config.dir=CONFIG_DIR com.salesforce.dataloader.process.ProcessRunner process.operation=insert
I would recommend extending (or creating another) process.bat file to support these parameters, instead of hard-coding it in process.bat. To do so, open process.bat and find this line
"%JAVA_HOME%\bin\java" -cp ..\dataloader-42.0.0-uber.jar -Dsalesforce.config.dir=%1 com.salesforce.dataloader.process.ProcessRunner %PROCESS_OPTION%

and add %3% at the end like this
"%JAVA_HOME%\bin\java" -cp ..\dataloader-42.0.0-uber.jar -Dsalesforce.config.dir=%1 com.salesforce.dataloader.process.ProcessRunner %PROCESS_OPTION% %3%

   Then when running process.bat add the parameter(s) in quotes
cd "C:\Program Files (x86)\\Data Loader\bin\"
process.bat ../myconfigdir AccountExport "\OutputDir\output %mydate%_%mytime%.csv"