问题
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