+ Start a Discussion
narendharnarendhar 

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" .
myatmyatmyatmyat
Hi Naren,

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

Thanks.

 
narendharnarendhar
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.
 
myatmyatmyatmyat
Hi Naren,

d:
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.

Thanks.
Menachem M ShanowitzMenachem M Shanowitz
The output file name is set with the dataAccess.name property which can be set dynamically in the command line. 
 
From https://github.com/forcedotcom/dataloader README

The command-line version runs with whatever properties you have in your config.properties 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 config.properties 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)\salesforce.com\Data Loader\bin\"
process.bat ../myconfigdir AccountExport "dataAccess.name=C:\OutputDir\output %mydate%_%mytime%.csv"