cancel
Showing results for 
Search instead for 
Did you mean: 

HCI-DS - How can I archive files with time stamp using scripts

0 Kudos

Hi Experts,

I want to move my files from C:\Files\* folder to C:\Files\Archive with a time stamp of sysdate().

I am using a "bat" file right now to move the folders from C:\Files to C:\Files\Archive without time stamp. How can I append time stamp before I move the files?

This is what I have used in move.bat file -

Move K:\DataFiles\* K:\DataFiles\Archive

Thanks,

Nihar

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hi All,

posting solution in case anyone is interested.

Create a batch script with below code and save the file as "LOCATION.BAT" in Archive folder. I want to move the file from C:\HCI\ folder to C:\HCI\Archive with timestamp.

In CPI, post load script - print (exec($G_BATCHFILE, ' ', 8)); where $G_BATCHFILE a global variable with value - 'C:\HCI\Archive\LOCATION.BAT'

@ECHO OFF

set mydate=%date:~10,4%%date:~4,2%%date:~7,2%

mytime=%time:~0,2%%time:~3,2%%time:~6,2%

REN C:\HCI\LOCATION_FF.CSV LOCATION_FF_%mydate%_%mytime%.csv

MOVE C:\HCI\LOCATION_FF*.CSV C:\HCI\Archive

Thanks,

Nihar

aalapati
Explorer
0 Kudos

Thanks Nihar,

This helped 🙂

Regards,

Aswini.