mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
I'm trying to write an alias to back up all of the files in my mIRC directory to another directory, but this doesn't work, because it doesn't seem to like me using *.*. I figure there is probably some identifier that I can use and this also would probably involve a loop, but I don't know what to do. Thanks for any help, and here's what I tried.

Code:
/backup {
  var %month = $gettok($date,1,47)
  var %day = $gettok($date,2,47)
  var %year = $gettok($date,3,47)
  var %newfolder = %month $+ %day $+ %year
  mkdir L:\ $+ %newfolder
  copy "C:\Program Files\mIRC\*.*" L:\tempbackup\ $+ %newfolder
}

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
did you try useing
Code:
/noop $findfile($mircdir,*.*,0,copy $gt($1-) $qt(%alLyourvarsettup $+ $nopath($1-)))

6.17+ only if I recall for the $qt()

Last edited by MikeChat; 01/08/06 03:41 AM.
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Small typo, should be $qt($1-):

Code:
noop $findfile($mircdir,*.*,0,copy $[color:red]q[/color]t($1-) $qt(%alLyourvarsettup $+ $nopath($1-)))

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
blush oops

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
rather than the gettok on $date you could use $asctime
Code:
alias makebackup {
  var %date = $asctime(mmddyyyy) $+ \
  mkdir L:\ $+ %date
  noop $findfile($mircdir,*.*,0,copy $qt($1-) $qt($+(L:\,%date,$nopath($1-))))
}
or for %date use $asctime(mm/dd/yyyy) $+ \


*not tested*

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Tested and works, but only for the main mIRC directory, not any sub-directories. If you want those as well, I can figure them out.
If this is going in your aliases, then as is will work. If in remotes, change the first line to alias backup {

Code:
 backup {
  if !$isdir(L:\tempbackup) {
    mkdir L:\tempbackup
  }
  if !$isdir($+(L:\tempbackup\,$date(ddmmyyyy))) {
    mkdir $+(L:\tempbackup\,$date(ddmmyyyy))
  }
  copy $nopath($mircdir*.*) $+(L:\tempbackup\,$date(ddmmyyyy),\)
}
 

Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
Thanks, RusselB. I used your code and it works. The only reason I was making my own variables for the date is because I'm used to seeing the date in MM/DD/YY format and it might confuse me if the day is first. Also, for now, it doesn't matter if I copy subdirectories. The only subdirectory I care about is the one with the logs in it, and I could just use $logdir. Thanks again.

Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
Actually, this is giving me a problem now. I have this.

Code:
/backup {
  if !$isdir(L:\tempbackup) {
    mkdir L:\tempbackup
  }
  if !$isdir($+(L:\tempbackup\,$date(ddmmyyyy))) {
    mkdir $+(L:\tempbackup\,$date(mmddyyyy))
  }
  copy $nopath($mircdir*.*) $+(L:\tempbackup\,$date(ddmmyyyy),\)
}


When I run it, it says:

* /copy: unable to open 'L:\tempbackup\01082006\address.txt' (line 321, aliases.ini)

Line 321 is
Code:
copy $nopath($mircdir*.*) $+(L:\tempbackup\,$date(ddmmyyyy),\)

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The only thing that I can think of, is that you tried to use the /backup command twice in the same day. To prevent this in future, I suggest adding the -o switch to the copy command.
That way if the files already exist they will be overwritten.

Regarding your preference of having the month first, rather than the day, this is simple to alter, just change the format of the parameter being supplied to $date. In this case, change ddmmyyyy to mmddyyyyy


Link Copied to Clipboard