|
Joined: Feb 2005
Posts: 344
Fjord artisan
|
OP
Fjord artisan
Joined: Feb 2005
Posts: 344 |
I'm looking for a script that copy's a file at the laast day of the month at 23:59 It should rename the file to <monthname_year.htm> is this possible ?
Greetzz
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Possible, but not simple, since mIRC doesn't know how many days there are in a month. Since you're wanting to do this just before midnight (by your post 1 minute before) would it make a big difference if the rename happened on the first of the next month just after midnight (ie: possibly 2 minutes later than what you asked for)?
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
You can always use $calc and add 1 day to the current date and see if the month changes. That wouldn't be too difficult with a timer and an IF statement for the $calc line.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Dec 2004
Posts: 66
Babel fish
|
Babel fish
Joined: Dec 2004
Posts: 66 |
I’m not sure if it will fit your situation, but when I have a log file that I want to start fresh at midnight, months end, etc I initialize the time of the current period and check that as I send input to the file. alias Init.LastSecOfMonth {
var %ThisMonth = $asctime(m)
var %ThisYear = $asctime(yyyy)
if (%ThisMonth < 12) var %NextMonth = $+($calc(%ThisMonth + 1),/,%ThisYear)
else var %NextMonth = $+(1/,$calc(%ThisYear + 1))
var %FirstSecNextMonth = $ctime(1/ $+ %NextMonth 0:00)
set %LastSecOfMonth $calc(%FirstSecNextMonth - 1)
echo -s $asctime(%LastSecOfMonth, y mmm yyyy H:nn)
echo -s $asctime(%FirstSecNextMonth, y mmm yyyy H:nn)
}
alias LogInput {
if ($ctime >= %LastSecOfMonth) {
var %NewFileName = $asctime(%LastSecOfMonth, mmm_yyyy) $+ .htm
echo -s %NewFileName
; Do file stuff
; re intialize %LastSecOfMonth
}
; do the logging
} The code is rough and long, but maybe you can adapt it to fit your situation.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
alias aliasNAMEHERE { if (!$1) { .timerNAMEHERE 23:59 1 0 aliasNAMEHERE CHECK | return } if ($1 == CHECK) { if ($date($ctime,mm) != $date($calc($ctime + 120),mm)) { copy "filename" $+(",$date(mmmm_yyyy),.htm") } .timer 1 120 aliasNAMEHERE } }
*usage /aliasNAMEHERE This well trip the timer off to go off at 23:59, with a $1 of "CHECK" When the timer goes off it checks if current month digits are not equal to the one in 2 mins, and if so copy "filename" to "month_year.htm", lastely either way it sets of a 120 second timer to set of the inital 23:59 timer, you dont want to set that off for 2 mins or so, to ensure that your not tripping it again becuase your still at say 23:59:02, aka delay 120 seconds to 00:01:02 and setup the timer again.
* u might want to consider using a vbs script or a /RUN CMD to do the copy if the file is large, as the internal copy command freezes up mirc for the time it takes to copy the file, if this is insignificant then dont worry about it., also if your going to then erase the file u might consider using /rename instead of /copy
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Here's the command for using /run:
/run -n cmd /c copy filename filename
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
Thanks i didnt know that <snicker snicker> and heres the .vbs scripted up as a command. ;Usage $copyfile(<source>,<destination>)[.force]
;
; $1 = sourcepath\file (must exist)
; $2 = destinationpath\file (must not exist, unless $copyfile().force property invoked)
;
alias copyfile {
if (($isfile($1)) && (($prop == force) || (!$isfile($2)))) {
if ((!$isfile($+($scriptdir,copy.vbs))) || ($file($+($scriptdir,copy.vbs)).size != 196)) {
write -c $+($scriptdir,copy.vbs) dim filesys
write $+($scriptdir,copy.vbs) dim args
write $+($scriptdir,copy.vbs) dim src
write $+($scriptdir,copy.vbs) dim dst
write $+($scriptdir,copy.vbs) set args = WScript.Arguments
write $+($scriptdir,copy.vbs) src = args.Item(0)
write $+($scriptdir,copy.vbs) dst = args.Item(1)
write $+($scriptdir,copy.vbs) set filesys = CreateObject("Scripting.FileSystemObject")
write $+($scriptdir,copy.vbs) filesys.CopyFile src, dst
}
run $qt($+($scriptdir,copy.vbs)) $qt($1) $qt($2)
}
} * be aware who ever uses it, its not valid filename checked, you can do that yourself if u like. *
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Sorry, wasn't meant as a reply to you, but just the info for that person. I assumed you knew since you mentioned it.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
lol yeah i knew u wouldnt have thought i didnt know. Thats why i added the "<snicker>" :-)
|
|
|
|
|