Batch file 如何批量从一系列字符串的左侧修剪字符串?
我有一些需要修改权限的用户共享。权限部分正在工作,但我正在尝试从文件夹路径中提取用户名。这些文件夹都是c:\user shares\j.smith格式的,我打算使用从takeown和其他命令中的路径获得的username变量 我的那批货生锈了,我敢肯定你听到了办公室里的吱吱声Batch file 如何批量从一系列字符串的左侧修剪字符串?,batch-file,cmd,Batch File,Cmd,我有一些需要修改权限的用户共享。权限部分正在工作,但我正在尝试从文件夹路径中提取用户名。这些文件夹都是c:\user shares\j.smith格式的,我打算使用从takeown和其他命令中的路径获得的username变量 我的那批货生锈了,我敢肯定你听到了办公室里的吱吱声 setlocal enabledelayedexpansion set find=C:\user shares\ FOR /D %%p IN ("c:\user shares\*") DO ( set str=%%
setlocal enabledelayedexpansion
set find=C:\user shares\
FOR /D %%p IN ("c:\user shares\*") DO (
set str=%%p
call set str=%%str:!find!=%%
echo %str%
)
pause
我对每个文件夹的输出如下
(
echo c:\user shares\j.smith
set uname=c:\user shares\j.smith
echo
set uname=%uname:!cut!=%
echo
)
c:\user shares\j.smith
ECHO is on.
ECHO is on.
我需要帮助解决这个基本问题,这样我才能真正了解字符串操作,我相信我也需要帮助
FOR /D %%p IN ("c:\user shares\*") DO (
echo %%~nxp
)
可以让您继续(显示%%p
的名称和扩展名部分)
但现在还不清楚你想发生什么这正是我想要的。非常感谢你。