如何在变量批处理编程中获取名称目录

时间:2015-07-13 23:14:47

标签: windows batch-rename

我试图使用目录的名称,但我无法在变量中获取该名称。这是我目前的剧本:

MKDIR "D:\Documents\testbatch\temp"  
SET TEMPDossier="D:\Documents\testbatch\temp"  
:Check  
CD /D D:\Documents\testbatch  
FOR /D %%x in (*_C_* ) do (  
CALL :fct_log_Texte INFO  " dossier disponible %%x"  
setlocal enabledelayedexpansion   
SET VarDossier= %%x  
ECHO !VarDossier!  
SET rename=!VarDossier!  
echo %rename%  
:: Quote the variable and remove the !  
Set rename="%rename:!=%"  

1 个答案:

答案 0 :(得分:0)

我无法理解你的代码,但是如果你想从它的完整路径获取目录名,你可以使用带有这样的变量的call命令:

@echo off
set fullpath="D:\Documents\testbatch\temp temp"
call :show %fullpath%
pause
goto :eof
:show
echo %~n1

如果您运行上面的批处理文件,它将在屏幕上打印临时温度。没有引号,不!这只是一个例子。我想你可以自己修改。我希望它对你有用。

相关问题