gpt4 book ai didi

string - 如何在Powershell中替换字符串?

转载 作者:行者123 更新时间:2023-12-03 00:53:43 25 4
gpt4 key购买 nike

我需要从文件路径中解压缩文件扩展名。
例如:我有一个类似的文件路径:

\\Test\data\data.dll

如何从文件路径中删除data.dll,这样我就只能
\\Test\data\

作为输出。

我尝试使用通配符-*。但这没用。

谢谢!

最佳答案

根据您的情况,默认情况下有一个特殊的cmdlet会删除文件或文件夹。尝试:

$path =  \\test\data\data.dll
#Get folderpath
Split-Path $path
#Get filename only (thanks to Christian for tip)
Split-Path $path -Leaf

关于string - 如何在Powershell中替换字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14277563/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com