Page 1 of 2 12>
Topic Options
#42949 - 2003-07-17 11:28 AM Archiving Files Append Date/Time Stamp
Paul Hutchins Offline
Fresh Scripter

Registered: 2003-07-17
Posts: 9
Loc: London, England
Before I begin, I am new to this scripting!

I wonder if you could help me?

I want to archive files and append the date/time stamp on the file name.

copy file1.txt file1datetimestamp.txt

Thanks in advance

Paul

Top
#42950 - 2003-07-17 11:37 AM Re: Archiving Files Append Date/Time Stamp
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
think you left out the big picture.
as you have always date stamp on files as their creation day changes on copy [Wink]

try something like:
code:
copy "file" "archive\file@year.@monthno.@mdayno"

think it gives some idea [Wink]
_________________________
!

download KiXnet

Top
#42951 - 2003-07-17 11:41 AM Re: Archiving Files Append Date/Time Stamp
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
paul, you could check also at our faq forum.
you have like three topics I would suggest to you.
starters guide, kixtart reference and abc's of the board.

anyway, welcome on the board.
_________________________
!

download KiXnet

Top
#42952 - 2003-07-17 11:44 AM Re: Archiving Files Append Date/Time Stamp
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
But will fail with error 3 If I am correct [Wink]

Copy cannot copy AND rename a file so you might want to split that into 2 :

1. KiX' copy command
2. shell to ren
_________________________



Top
#42953 - 2003-07-17 11:48 AM Re: Archiving Files Append Date/Time Stamp
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
jochen?
why you confuse me? [Confused]

sure it works! [Big Grin]

haven't you ever copied files with kix? [Razz]

[ 17. July 2003, 11:49: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#42954 - 2003-07-17 11:49 AM Re: Archiving Files Append Date/Time Stamp
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
not really ... lemme try<

[always used to copy whole directories by xcopy or robocopy [Roll Eyes] ]

[ 17. July 2003, 11:50: Message edited by: Jochen ]
_________________________



Top
#42955 - 2003-07-17 11:52 AM Re: Archiving Files Append Date/Time Stamp
Paul Hutchins Offline
Fresh Scripter

Registered: 2003-07-17
Posts: 9
Loc: London, England
Thankyou for your replies.

I will be running the script on NT. I have tried the following but is does not work.

Break OFF

If 1=Exist("C:\new\FIXServer.log")
Copy "C:\new\FIXServer.log" "C:\new\FIXServerfile@year.@monthno.@mdaynolog"

EndIf
Exit

Should I try the rename command?

Top
#42956 - 2003-07-17 11:53 AM Re: Archiving Files Append Date/Time Stamp
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
YUK !

Invalid character alert ... I will go now hiding under next rock for trying to use @date in filename [Mad] [Embarrassed] [Mad] [Embarrassed] [Mad]

[ 17. July 2003, 12:07: Message edited by: Jochen ]
_________________________



Top
#42957 - 2003-07-17 11:55 AM Re: Archiving Files Append Date/Time Stamp
Paul Hutchins Offline
Fresh Scripter

Registered: 2003-07-17
Posts: 9
Loc: London, England
Constructive critism comes to mind.....

So what should the syntax be?

Top
#42958 - 2003-07-17 11:57 AM Re: Archiving Files Append Date/Time Stamp
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
paul, you missed one dot from you script.

anyway, try this as it shows if there is error what it is:
If 1=Exist("C:\new\FIXServer.log") 
Copy "C:\new\FIXServer.log" "C:\new\FIXServerfile@year.@monthno.@mdayno.log"
if @error
? "error occured: @error - @serror"
? "script will exit once you press a key"
get $
exit 1
endif
EndIf



btw, exit is not needed as script is exitted automatically.
also, break off is not needed as it's off by default.
_________________________
!

download KiXnet

Top
#42959 - 2003-07-17 11:57 AM Re: Archiving Files Append Date/Time Stamp
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Lonk,

it works indeed [Roll Eyes]

Paul,

you miss a dot before your file extension
_________________________



Top
#42960 - 2003-07-18 12:00 AM Re: Archiving Files Append Date/Time Stamp
Paul Hutchins Offline
Fresh Scripter

Registered: 2003-07-17
Posts: 9
Loc: London, England
Thanks for your time.
Top
#42961 - 2003-07-18 12:01 AM Re: Archiving Files Append Date/Time Stamp
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oh, jochen... isn't that sweet [Big Grin]
got one big smile on my face, thanks!
it's good to wake up smiling.

btw, paul, you should really read that ABC of board etiquette.
like, when you post scripts, you should post them in  - tags to preserve the formatting.
or use postprep, but as long as your scripts are small, the code-tags are best option.

this way the scripts remain the readability.
you know what I mean [Wink]
_________________________
!

download KiXnet

Top
#42962 - 2003-07-18 12:12 AM Re: Archiving Files Append Date/Time Stamp
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Oh hey Paul...

Only for the case you misunderstood my ' [Mad] [Embarrassed] ' -reply :

It was not meant as order in your direction but a description of what I should do.

Edited my sentence accordingly [Roll Eyes] [Smile]
_________________________



Top
#42963 - 2003-07-18 12:40 AM Re: Archiving Files Append Date/Time Stamp
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Example code with the date format appended to the end of the folder that you are backing up.

E.G E:\CapitalCharge - 240503\

code:
$DATE = SubStr( @DATE, 9, 2 ) + SubStr( @DATE, 6, 2 ) + SubStr( @DATE, 1, 4 )
MD "E:\CapitalCharge - $DATE"
Copy "C:\CapitalCharge" "E:\CapitalCharge - $DATE" /h

This may be of some help.

Thanks

Rich

Top
#42964 - 2003-07-17 04:56 PM Re: Archiving Files Append Date/Time Stamp
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Or
code:
$date=join(split(@DATE),'\'),'.')

to reformat the @DATE into a valid format.
_________________________
There are two types of vessels, submarines and targets.

Top
#42965 - 2003-07-17 05:08 PM Re: Archiving Files Append Date/Time Stamp
Paul Hutchins Offline
Fresh Scripter

Registered: 2003-07-17
Posts: 9
Loc: London, England
Hi,

Thank you for your reply to my little problem.

This is my script so far
code:
  
If 1=Exist("C:\new\FIXServer.log")
Copy "C:\new\FIXServer.log" "C:\new\FIXServer@mdayno.@monthno.@year.log"
If @error
? "error occured: @error - @serror"
? "script will exit once you press a key"
Get $
Exit 1
EndIf
EndIf

The problem I now have is that I need to put a time stamp in the file name as well. The time stamp is required, because if the file is written twice (due to a restart of a service) I will loose a log that has already been archived.

All your help appreciated.

Top
#42966 - 2003-07-17 05:10 PM Re: Archiving Files Append Date/Time Stamp
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Then use the @TIME macro, too.
code:
$datetime=join(split(@DATE,'\'),'-')+join(split(@TIME,':'),'-')

_________________________
There are two types of vessels, submarines and targets.

Top
#42967 - 2003-07-17 05:13 PM Re: Archiving Files Append Date/Time Stamp
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
rehashing old info [Razz]
http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=005218#000003
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#42968 - 2003-07-17 05:14 PM Re: Archiving Files Append Date/Time Stamp
Paul Hutchins Offline
Fresh Scripter

Registered: 2003-07-17
Posts: 9
Loc: London, England
So where would the following fit in my script?

code:
  
$datetime=join(split(@DATE,'\'),'-')+join(split(@TIME,':'),'-')


Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.075 seconds in which 0.027 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org