通过DIR搜索文件后转到目录 [英] change to directory after searching for the file via DIR
本文介绍了通过DIR搜索文件后转到目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
结果是在通过cmd通过DIR搜索文件后将结果更改为目录
Outcome is to change to directory after searching for the file via DIR through cmd
文件位置为C:\ Folder
Location of file is C:\Folder
以下代码可能吗?
set /a variable= dir document.doc /s /p
cd %%variable%%
将目录更改为C:\ Folder
Change directory to C:\Folder
推荐答案
尝试一下:
for /f "delims=" %%# in ('dir document.doc /s /b') do (
set "new_dir=%%~dp#"
)
cd /d "%new_dir%"
这篇关于通过DIR搜索文件后转到目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文