仅使用批处理文件修剪前斜线 [英] Trim leading slashes using only a batch file
问题描述
对于我在哪里工作,我的手是绑在我可以使用,以做我想要的。
我需要做的是创建一个 .bat
执行 net视图
并将其输出到 .txt
并从输出中删除前导斜线。
获取网络视图到文件是很容易的部分,但删除前面的斜线是我遇到的问题。 / p>
不确定是否会影响,但我公司使用的命名系统是 ##### - XX - ##
我已经看了一会儿,无法找到一种方法来轻松做到这一点。
编辑:Powershell
PowerShell:
net view | select-string'^ \\\\([^ \\\s] +)'| foreach-object {
$ _。Matches [0] .Groups [1] .Value
} | out-file netview.txt
帐单
For where I work my hands are tied on what I can use in order to do what I want.
What I need to do is create a .bat
that does a net view
and outputs it to a .txt
and remove the leading slashes from the output.
Getting the net view to a file is the easy part but removing the leading slashes is what I am having an issues with.
Not sure if it will matter but the naming system that my company uses is #####-XX-##
I have looked around quite a bit and have not been able to find a way to easily do this.
EDIT: Powershell is also something that could be used if someone has a script for that.
PowerShell:
net view | select-string '^\\\\([^\\\s]+)' | foreach-object {
$_.Matches[0].Groups[1].Value
} | out-file netview.txt
Bill
这篇关于仅使用批处理文件修剪前斜线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!