how to move a file to new location with time stamp

Post Reply
User avatar
SKSKD
Nouveau
Nouveau
Posts: 9
Joined: 12 Aug 2013 12:00

how to move a file to new location with time stamp

Post by SKSKD » 09 May 2014 4:22

Suppose my file in X location is ->ABCD.txt

Move to Y location with appending timestamp.
like
ABCD.20140509094707.txt

What i did

But the out put I am getting in job after difined a variable is
ABCD.20140509094707txt

Where variable defined is
%%TIMEST=%%$DATE.%%TIME
And command is
move D:\ABCD.txt D:\DD\ABCD.%%TIMEST.txt

But the output is ABCD.20140509094707txt

so file type is not recognized as .txt as "." missing before "txt"

Thanks for your valuable inputs here
I am working on Control-M V8

User avatar
jCarlos
Nouveau
Nouveau
Posts: 36
Joined: 19 Jun 2013 12:00

Post by jCarlos » 10 May 2014 5:23

could you try something like:

move D:\ABCD.txt D:\DD\ABCD."%%TIMEST".txt

or

move D:\ABCD.txt D:\DD\ABCD."%TIMEST%".txt

or set a cmd variable like:

set ts=%%TIMEST & move D:\ABCD.txt D:\DD\ABCD."%ts%".txt

i don't have the enviroment to test right now, the last one will work as you are using "move" so you are using a windows based os.

User avatar
SKSKD
Nouveau
Nouveau
Posts: 9
Joined: 12 Aug 2013 12:00

Post by SKSKD » 13 May 2014 6:12

jCarlos wrote:could you try something like:

move D:\ABCD.txt D:\DD\ABCD."%%TIMEST".txt

or

move D:\ABCD.txt D:\DD\ABCD."%TIMEST%".txt

or set a cmd variable like:

set ts=%%TIMEST & move D:\ABCD.txt D:\DD\ABCD."%ts%".txt

i don't have the enviroment to test right now, the last one will work as you are using "move" so you are using a windows based os.
Thanks Carlos,

It working fine for me.

Thanks once again

User avatar
jCarlos
Nouveau
Nouveau
Posts: 36
Joined: 19 Jun 2013 12:00

Post by jCarlos » 15 May 2014 5:24

I'm glad I could be of assistance :)

User avatar
matom
Nouveau
Nouveau
Posts: 37
Joined: 29 Nov 2006 12:00
Location: Ile de France

Post by matom » 19 May 2014 11:04

Hi SKSKD,

Use two consecutive « . » to include one in your file name.

Your command is :
move D:\ABCD.txt D:\DD\ABCD.%%TIMEST..txt

Regards

User avatar
ThePirate
Nouveau
Nouveau
Posts: 61
Joined: 04 Feb 2008 12:00
Location: Cleveland, OH

Post by ThePirate » 19 May 2014 4:59

If you are using the CM for Advanced File Transfer to move the file use below

for D:\DD\$$AFTFILE$$.%%$DATE.%%TIME for ABCD.yyyymmddhhmmss.txt (need dot after last $ sign to get the dot after ABCD)

and use D:\DD\$$AFTFILE$$%%$DATE.%%TIME for ABCDyyyymmddhhmmss.txt but I think you are using some kind of script.

Post Reply