[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[其他] 批处理中%0的扩展是什么意思?

本帖最后由 pcl_test 于 2016-8-7 22:53 编辑

echo %~t0
echo %~z0
echo %~dp0
echo %~dp0  echo %~x0
echo %~nx0
echo %~0
  什么意思啊 就是说echo后面的意思
ss

其它的都懂了就这个不会?
其实一样简单的呀。
  1. @echo off
  2. for /f "tokens=1-3 delims=- " %%a in ('echo %date%') do echo %%a年%%b月%%c日
  3. pause
复制代码
在上面代码中,FOR会先执行echo %date%,然后把它执行的结果传递给FOR,FOR
再以选项delims=- 来分隔它

大概就是这样子的啦,多看看别人的代码,自己写些简单的代码慢慢的就会了
不大可能的事也许今天实现,根本不可能的事也许明天会实现

TOP

回复 5楼 的帖子

版主能不能帮我讲解一下FOR /F ["options"] %%i IN ('command') DO command 中的 ('command')

顺便举些例子  for的其他命令我懂了  就这个  谢谢诶了
ss

TOP

回复 5楼 的帖子

谢谢  慢慢研究 呵呵   谢谢诶帮忙
ss

TOP

  1. @echo off
  2. set "file=C:\Program Files\Internet Explorer\HMMAPI.DLL"
  3. for /f "delims=" %%a in ("%file%") do echo %%~dpa
  4. rem   上面这个就是显示驱动器号和路径
  5. for /f "delims=" %%a in ("%file%") do echo %%~nxa
  6. rem   上面这个就是显示文件名和文件扩展名
  7. for /f "delims=" %%a in ("%file%") do echo %%~fsa
  8. rem   上面这个就是显示有短名的完整路径名,注意这里是短名
  9. rem  如c:\progra~1\intern~1之类的
  10. rem  in前面是%%a,后面就用%%~fsa,如果前面是%%i那后面就用%%~fsi
  11. pause
复制代码
1

评分人数

不大可能的事也许今天实现,根本不可能的事也许明天会实现

TOP

c:\>call/?
Calls one batch program from another.
CALL [drive:][path]filename [batch-parameters]
  batch-parameters   Specifies any command-line information required by the
                     batch program.
If Command Extensions are enabled CALL changes as follows:
CALL command now accepts labels as the target of the CALL.  The syntax
is:
    CALL :label arguments
A new batch file context is created with the specified arguments and
control is passed to the statement after the label specified.  You must
"exit" twice by reaching the end of the batch script file twice.  The
first time you read the end, control will return to just after the CALL
statement.  The second time will exit the batch script.  Type GOTO /?
for a description of the GOTO :EOF extension that will allow you to
"return" from a batch script.
In addition, expansion of batch script argument references (%0, %1,
etc.) have been changed as follows:

    %* in a batch script refers to all the arguments (e.g. %1 %2 %3
        %4 %5 ...)
    Substitution of batch parameters (%n) has been enhanced.  You can
    now use the following optional syntax:
        %~1         - expands %1 removing any surrounding quotes (")
        %~f1        - expands %1 to a fully qualified path name
        %~d1        - expands %1 to a drive letter only
        %~p1        - expands %1 to a path only
        %~n1        - expands %1 to a file name only
        %~x1        - expands %1 to a file extension only
        %~s1        - expanded path contains short names only
        %~a1        - expands %1 to file attributes
        %~t1        - expands %1 to date/time of file
        %~z1        - expands %1 to size of file
        %~$PATH:1   - searches the directories listed in the PATH
                       environment variable and expands %1 to the fully
                       qualified name of the first one found.  If the
                       environment variable name is not defined or the
                       file is not found by the search, then this
                       modifier expands to the empty string
    The modifiers can be combined to get compound results:
        %~dp1       - expands %1 to a drive letter and path only
        %~nx1       - expands %1 to a file name and extension only
        %~dp$PATH:1 - searches the directories listed in the PATH
                       environment variable for %1 and expands to the
                       drive letter and path of the first one found.
        %~ftza1     - expands %1 to a DIR like output line
    In the above examples %1 and PATH can be replaced by other
    valid values.  The %~ syntax is terminated by a valid argument
    number.  The %~ modifiers may not be used with %*

[ 本帖最后由 pusofalse 于 2008-7-31 23:46 编辑 ]
心绪平和,眼藏静谧。

TOP

版主  谢谢  但还是麻烦一下   我看了 但是%~dpi  %~nxi  %~fsi  还是不懂    能不能解释一下上面  顺便举些例子  谢谢诶 本人最近疯狂的在学批处理   现在遇到一些问题   还有 FOR /F ["options"] %%i IN (file) DO command
FOR /F ["options"] %%i IN ("string") DO command
FOR /F ["options"] %%i IN ('command') DO command  中的FOR /F ["options"] %%i IN ('command') DO command 不懂 能告诉一下  举些例子 好吗 谢谢版主了 o(∩_∩)o...
ss

TOP

cmd中键入for /?回车到信息的最后一页。
***共同提高***

TOP

返回列表