How to rename and move a file to new location when we use a command line data loader

I have been using command line data loader quite a long time but many times we wanted to rename the processed file by adding the current data and time and move it to a different location.

Here is the script for it

SET DAY=%DATE:~4,2%
SET MTH=%DATE:~7,2%
SET YR=%DATE:~10,4%
SET HR=%TIME:~0,2%
SET HR0=%TIME:~0,1%
IF “%HR0%”==” ” SET HR=0%TIME:~1,1%
SET MIN=%TIME:~3,2%
SET SEC=%TIME:~6,2%
SET MYDATE=%YR%%MTH%%DAY%-%HR%%MIN%%SEC
ren ..\csv\myFile.csv myFile_%MYDATE%.csv
move ..\csv\myFile_%MYDATE%.csv ..\csv\processed\myFile_%MYDATE%.csv

ren command is used to rename the file with current date time where as move command is used to move the file to a new folder

Note: ..\ means this is a relative location, or else you can even hard code the entire path 🙂

Advertisements
This entry was posted in salesforce, Salesforce Tips & Tricks, Uncategorized. Bookmark the permalink.

One Response to How to rename and move a file to new location when we use a command line data loader

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s