[电脑] 2025-05-06 圈点262
摘要:windows在bat文件代码中取盘符和文件夹等路径命令和变量,作用用法:在一个.bat 文件中,可以使用上面这些变量来获取当前文件所在的盘符、文件路径,文件名等内容。
windows在bat文件代码中取盘符和文件夹等路径命令和变量
echo 当前盘符:%~d0 echo 当前盘符和路径:%~dp0 echo 当前批处理全路径:%~f0 echo 当前盘符和路径的短文件名格式:%~sdp0 echo 当前CMD默认目录:%cd% echo 目录中有空格也可以加入""避免找不到路径 echo 当前盘符:"%~d0" echo 当前盘符和路径:"%~dp0" echo 当前批处理全路径:"%~f0" echo 当前盘符和路径的短文件名格式:"%~sdp0" echo 当前CMD默认目录:"%cd%" pause
作用用法:在一个.bat 文件中,可以使用上面这些变量来获取当前文件所在的盘符、文件路径,文件名等内容。
bat示例截图:
英文解释:
%n contains the arguments used to invoke the file: %0 is the path to the bat-file itself, %1 is the first argument after, %2 is the second and so on.
~d is drive.
~p is the path (without drive).
~n is the file name.
~dp is drive+path.
~t is the timestamp.
~z is the size.
上一篇[电脑]fiddler最常用的几个快捷键
下一篇[电脑]windows xp系统的回忆整理