Saturday, April 6, 2013

Trim leading slashes using only a batch file

CMD (replace %m with %%m for running this in a batch file):

for /f "delims=\ tokens=*" %m in ('net view ^| findstr /r "^\\\\"') do (
  echo %m
) >out.txt
 
 
PowerShell:

net view | select-string '^\\\\' -AllMatches `
  | % { $_ -replace '^\\\\', '' } >out.txt

No comments:

Post a Comment