仅从文件的完整路径中获取文件名 [英] Get only filename from full path of a file

查看:42
本文介绍了仅从文件的完整路径中获取文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想拆分路径并将文件名test.xls保存在一个新变量中

I want to split the path and just save the file name test.xls in a new variable

$namearray = "C:\Users\z003m\Desktop\Service_Tickets\automationscript\vbs\Newfolder\test.xls"

推荐答案

推荐使用内置的Split-Path:

$newVariable = Split-Path $namearray -Leaf

这篇关于仅从文件的完整路径中获取文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆