mIRC Homepage
Posted By: bwr30060 copying each file in mIRC directory - 01/08/06 02:28 AM
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
}
Posted By: MikeChat Re: copying each file in mIRC directory - 01/08/06 03:39 AM
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()
Posted By: hixxy Re: copying each file in mIRC directory - 01/08/06 03:55 AM
Small typo, should be $qt($1-):

Code:
noop $findfile($mircdir,*.*,0,copy $[color:red]q[/color]t($1-) $qt(%alLyourvarsettup $+ $nopath($1-)))
Posted By: MikeChat Re: copying each file in mIRC directory - 01/08/06 03:56 AM
blush oops
Posted By: MikeChat Re: copying each file in mIRC directory - 01/08/06 04:09 AM
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*
Posted By: RusselB Re: copying each file in mIRC directory - 01/08/06 04:12 AM
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),\)
}
 
Posted By: bwr30060 Re: copying each file in mIRC directory - 01/08/06 12:52 PM
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.
Posted By: bwr30060 Re: copying each file in mIRC directory - 01/08/06 05:08 PM
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),\)
Posted By: RusselB Re: copying each file in mIRC directory - 01/08/06 10:19 PM
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
© mIRC Discussion Forums