From WikiChip
/write Command - mIRC
< mirc‎ | commands(Redirected from /write)

The /write command can be used to manipulate a text file in various ways. Used without switches mIRC will append the line to the end of the text file. If the file does not exist, mIRC will create it. If <words>, <wildcard>, or <regex> contains spaces, they must be enclosed by a pair of quotes.

Synopsis[edit]

/write [-cidnamN l<line> s<words> w<wildcard> r</regex/>] <filename> [text]

Switches[edit]

  • -c - Clears the entire file before writing to it
  • -i - Inserts the text at a given line instead of replacing it
  • -d - Deletes the given line
  • -n - Prevent adding $crlf at the end of the text
  • -a - Appends the text to an existing line
  • -l - Line number for the line to write/modify/delete
  • -s - Operates on a line which start with <words>
  • -w - Operates on a line which match the <wildcard> expression.
  • -r - same as -w - but uses a regular expression.
  • -W - line read from a file is treated as the wildcard
  • -R - line read from a file is treated as the regex
  • -mN - handle the $crlf addition before a line:
  There is a difference in how /write behave vs /write -s or /write -w when it comes to adding a $crlf before your line, if mirc is going to add the line to end of the file and that the last line does not have a $crlf already.
  /write will always put the $crlf, whereas /write -ws won't. For compatibility and to allow you to control exactly when and if a $crlf is going to be added in this case:
  When N = 0, the current behavior is used, N = 1 means a $crlf is added only if a $crlf isn't always there, N = 2 means a $crlf is never added.

Parameters[edit]

  • <filename> - The file name to manipulate
  • [text] - The text to be written to the file
  • <line> - The line number to find
  • <words> - The word to scan.
  • <wildcard> - Wildcard pattern to match
  • </regex/> - RegEx pattern to match

Example[edit]

Alias Example {
  ;Create a file; add a few lines of text to it
  write Example.txt this is a cool line
  write Example.txt hello there!
  write Example.txt text files are cool
 
  /*
    Locate the line that starts with "hello" 
    and insert the following text before it
  */
  write -is"Hello" Example.txt This will become line 2! 
 
  ;Delete line 1
  write -dl1 Example.txt
}

Compatibility[edit]

Added: mIRC v3.8
Added on: 25 Nov 1995
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.


See also[edit]

v · d · e mIRC commands list

A /abook, /action, /add, /ajinvite, /alias, /aline, /ame, /amsg, /anick, /aop, /auser, /auto, /autojoin, /avoice, /away

B /background, /ban, /bcopy, /beep, /bindip, /bread, /break, /breplace, /bset, /btrunc, /bunset, /bwrite

C /channel, /clear, /clearall, /clearial, /cline, /clipboard, /close, /closechats, /closedccs, /closefserves, /closemsg, /cnick, /color, /colour, /comclose, /comlist, /commands, /comopen, /comreg, /continue, /copy, /creq, /ctcp, /ctcpreply, /ctcps

D /dcc, /dccserver, /dde, /ddeserver, /debug, /dec, /describe, /dialog, /did, /didtok, /disable, /disconnect, /dlevel, /dline, /dll, Template:mIRC/donotdisturb, /dns, /dqwindow, /drawcopy, /drawdot, /drawfill, /drawline, /drawpic, /drawrect, /drawreplace, /drawrot, /drawsave, /drawscroll, /drawsize /drawtext

E /ebeeps, /echo, /editbox, /else, /elseif, /emailaddr, /enable, /events, /exit

F /fclose, /filter, /findtext, /finger, /firewall, /flash, /flist, /flood, /flush, /flushini, /fnord, /font, /fopen, /fseek, /fsend, /fserve, /fullname, /fupdate, /fwrite

G /ghide, /gload, /gmove, /gopts, /goto, /gplay, /gpoint, /gqreq, /groups, /gshow, /gsize, /gstop, /gtalk, /gunload, /guser

H /hadd, /halt, /haltdef, /hdec, /hdel, /help, /hfree, /hinc, /hload, /hmake, /hotlink, /hop, /hsave

I /ial, /ialclear, /ialmark, /identd, /if, /ignore, /iline, /inc, /iuser

J /join

L /leave, /linesep, /links, /list, /load, /loadbuf, /localinfo, /log, /logview

M /maxdepth, /mdi, /me, /menubar, /mkdir, /mnick, /mode, /msg

N /noop, /notice, /notify

O /onotice, /omsg

P /pareline, /part, /partall, /pdcc, /perform, /play, /playctrl, /pop, /protect, /proxy, /pvoice

Q /qme, /qmsg, /query, /queryrn, /quit, /quote

R /raw, /registration, /reload, /remini, /remote, /remove, /rename, /renwin, /reseterror, /resetidle, /return, /returnex, /rlevel, /rline, /rmdir, /run, /ruser

S /save, /savebuf, /saveini, /say, /scid, /scon, /server, /set, /setlayer, /showmirc, /signal, /sline, /sockaccept, /sockclose, /socklist, /socklisten, /sockmark, /sockopen, /sockpause, /sockread, /sockrename, /sockudp, /sockwrite, /sound, /speak, /splay, /sreq, /strip, /switchbar

T /timer, /timestamp, /tip, /tips, /titlebar, /tnick, /tokenize, /toolbar, /topic /tray, /treebar

U /ulist, /unload, /unset, /unsetall, /updatenl, /url, /username, /uwho

V /var, /vcadd, /vcmd, /vcrem, /vol

W

X /xyzzy