Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 如何批量从一系列字符串的左侧修剪字符串?_Batch File_Cmd - Fatal编程技术网

Batch file 如何批量从一系列字符串的左侧修剪字符串?

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=%%

我有一些需要修改权限的用户共享。权限部分正在工作,但我正在尝试从文件夹路径中提取用户名。这些文件夹都是c:\user shares\j.smith格式的,我打算使用从takeown和其他命令中的路径获得的username变量

我的那批货生锈了,我敢肯定你听到了办公室里的吱吱声

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
的名称和扩展名部分)


但现在还不清楚你想发生什么

这正是我想要的。非常感谢你。