All pastes #995449 Raw Edit

Yajirobe

public text v1 · immutable
#995449 ·published 2008-04-24 05:06 UTC
rendered paste body
alias slashes {
  var %dir = $?="Enter the path of your windower script directory"
  if (!$isdir(%dir)) { echo -a Directory not found/specified. | return }
  var %temp , %count = 0 , %i = 1 , %files = $findfile(%dir,*,0)
  while (%i <= %files) {
    var %j = 1 , %file = $findfile(%dir,*,%i)
    while ($read(%file,r,/^(?:\s*)(?:alias \S+ )?exec\b/,%j)) {
      if ($regsub($v1,/((?:[^\\]+|(?:\\\\)+)+)((?:\\)?)(?!\\)/g,\1\2\2,%temp) > 1) {
        write -l $+ $readn %temp
        inc %count
      }
      %j = $calc($readn + 1)
    }
    inc %i
  }
  echo -a %count replacements made
}