mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
ok redirecting a incoming file to a new folder is simple enough.

And you can rename a incoming file if your accepting them manually "save as".

So how do you do it from a script? (pre download)

Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
There's no easy way to do that. If you want, you can rename files that already exist in your download folder before the newely received file is accepted. See this post for an example.

Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
You can't do it before downloading, only afterwards. Then you can simple use the on FILERCVD event and /rename $filename whatever


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
That's right. The only thing he can do before download is to rename existing files so mIRC won't ask if he wants to resume/overwrite them.

Joined: Sep 2003
Posts: 4,230
D
DaveC Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
It can be done actually i scripted it when i was told there was no function/command to do it, and was going to say earlier, but thought i better see if i can add dcc resume support in as well.

Its not the most pretty of things, as ON FILERCVD and ON GETFAIL dont respond correctly anymore, but that wasnt important for what i was doing so its liveable.

Ill post the code if anyone is interested. (didnt here as id have to cut it out of where it is)

Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
I'd like to see it

Joined: Sep 2003
Posts: 4,230
D
DaveC Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I added an example dcc.send.newfilename alias so it would be esier to see whats happening.

I wouldnt mind some feed back, im sure it can be crashed/broken if someoen really tried, but for most normal sends it would be fine.

Code:
 
;
;Description : Rename dcc send files before download begins.
;
;Method of rename described below...
;
;The CTCP ^*:DCC SEND *: event requests a identifier value using $DCC.SEND.NEWFILENAME(sendernick,filename,ipaddress,port,filesize)
;  this value is used as the filename, you can return any valid filename or $null (returning the same filename or $null well bypass the renaming)
;
;
;A example alias DCC.SEND.NEWFILENAME has be included below which simply adds the nick to the front of the filename unless it is a .TXT file.
;
alias dcc.send.newfilename {
  if ($1 != $null) {
    ;
    ; ** $1-5 = sendernick filename ipaddress port filesize
    ;
    if (*.TXT iswm $2) {
      return
    }
    else {
      return $replace($1,&,&26,\,&5C,/,&2F,:,&3A,*,&2A,?,&3F,",&22,<,&3C,>,&3E,|,&7C) $+ . $+ $2
      ;      ^^ ** some charcters cant be in filenames so i fix any that might appear (i know some cant appear in nicks as well) **
    }
  }
}
;
;
;
CTCP ^*:DCC SEND *:{
  ;  
  ; ** correct $1- to deal with files with spaces in. 
  ;
  tokenize 62 DCC $+ > $+ SEND $+ > $+ $nopath($filename) $+ > $+ $gettok($1-,-3,32) $+ > $+ $gettok($1-,-2,32) $+ > $+ $gettok($1-,-1,32)
  ;
  ; ** $1-6 now = DCC SEND filename ipaddress port filesize
  ;
  if (($nick != $me) && ($dcc.send.newfilename($nick,$3,$4,$5,$6) != $4)) {
    var %newfilename = $ifmatch
    if (%newfilename != $null) {
      set -u1000 %dcc.send.newfilename. [ $+ [ $5 ] ] $nick
      msg $me $chr(1) $+ DCC SEND $+(",%newfilename,") $4 $5 $6 $+ $chr(1)
      halt
    }
  }
}
;
CTCP ^*:DCC RESUME *:{
  ;
  ; ** $1-5 = DCC RESUME filename port position
  ; 
  if (($nick == $me) && (%dcc.send.newfilename. [ $+ [ $gettok($1-,-2,32) ] ] != $null)) {
    msg $ifmatch $chr(1) $+ $1- $+ $chr(1)
    halt
  }
}
;
CTCP ^*:DCC ACCEPT *:{
  ;
  ; ** $1-5 = DCC ACCEPT filename port position
  ; 
  if (($nick != $me) && (%dcc.send.newfilename. [ $+ [ $gettok($1-,-2,32) ] ] != $null)) {
    msg $me $chr(1) $+ $1- $+ $chr(1)
    halt
  }
}
;
;

; * added these so you can see the junking of the $nick, it comes out as your own, for obvious reasons *
on *:FILERCVD:*:echo -s FILERCVD $filename from $nick at $address
on *:GETFAIL:*: echo -s GETFAIL. $filename from $nick at $address

 


essentially it intercepts dcc send and changes the filename then msgs myself a dcc send with the new filename, halting the original.
dcc resume and dcc accept work on the same princable.

PS: The 1000 second set erase might have been overkill, but i didnt like the idea of accessing the mirc.ini for the true timeout value.

Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Smart idea indeed smile


Link Copied to Clipboard