Command Prompt Navigation: Navigating To An Unknownly Named Folder

纵饮孤独 提交于 2019-12-25 03:44:32

问题


So, is there any way to navigate your command prompt to/through a location which's name you don't know exactly?

For example the situation is i want to rename the sei.dat file and its located at:

C:/programdata/CsD2/Tools/("THE UNKNOWN VERSION NAMED FOLDER")/data/per/sei.dat

So as you can see i know where the software is installed however the folder after "Tools" folder is named after the version of the tools (example V0.1.2.6) and it changes often. Is there any command or way to navigate the Command Prompt to the files location? Or if not is there any way to modify the file without navigating the Command Prompt to the location?

I just want to rename the file but i don't know the name of the folder marked as "THE UNKNOWN VERSION NAMED FOLDER"


回答1:


Test this:

@echo off
for /f "delims=" %%a in ('dir /b /s /a-d "C:\programdata\CsD2\Tools\sei.dat" ') do set "folder=%%~dpa"
if not defined folder echo sei.dat was not found & pause & goto :EOF
cd /d "%folder%"
cmd /k


来源:https://stackoverflow.com/questions/24890384/command-prompt-navigation-navigating-to-an-unknownly-named-folder

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!