windows – 从批处理文件的目录中复制文件
发布时间:2020-12-13 22:48:41 所属栏目:Windows 来源:网络整理
导读:我只知道编写批处理文件的基础知识.我试图弄清楚如何编写一个,在给定任何目录的情况下,它将复制同一目录中的文件并将其放在新位置.我知道如何复制文件并移动它,但我不知道如何编写批处理文件以了解其目录,然后获取另一个文件. 我读到%0表示文件所在的目录,
我只知道编写批处理文件的基础知识.我试图弄清楚如何编写一个,在给定任何目录的情况下,它将复制同一目录中的文件并将其放在新位置.我知道如何复制文件并移动它,但我不知道如何编写批处理文件以了解其目录,然后获取另一个文件.
我读到%0表示文件所在的目录,但是如何将文件附加到该目录? 我试过这个: copy "%0Move.txt" "C:" 也许那是愚蠢但我是新手.请帮忙?
%0包含批处理脚本的完整路径和文件名.
仅使用%~dp0获取没有批处理脚本文件名的路径. copy "%~dp0Move.txt" "C:" 使用echo命令查看遇到问题时变量的含义. echo %0 来自/? 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 %* (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 语音识别 – 如何在Windows中为sox安装flac支持(flac库)
- .net – 当发布dll不工作但调试dll的时候
- 在Windows上运行远程命令,如linux上的ssh -c
- windows-7 – 在XP Mode和VMware之间选择在Windows 7上进行
- windows – 如何解决CoUnitialize()上挂起的进程?
- Postgres绿色版本安装 windows
- windows-server-2012 – 可以使用填充程序来更改Windows版本
- 一款VS开发利器-Visual Assist X
- Windows Phone 8 – 无法在Windows Phone 8上安装公司应用程
- windows – 按应用程序跟踪带宽使用情况