Page 1 of 1
i need a batch to find the 1st level of dir name and the 2nd
Posted: 01 Oct 2022 07:51
by nnnmmm
Code: Select all
path = "M:\11 11\22 22\33 33\44 44\A B C D.TXT"
definition :
1st level dir name is 11 11
2nd level dir name is 22 22
i need a batch to find the 1st level of dir name and the 2nd
Re: i need a batch to find the 1st level of dir name and the 2nd
Posted: 01 Oct 2022 09:47
by ShadowThief
%PATH% is already a system variable, so you should call it something else. After that, you can simply delimit the string on
\ and grab the second and third tokens.
Code: Select all
@echo off
set "full_path=M:\11 11\22 22\33 33\44 44\A B C D.txt"
for /f "tokens=2,3 delims=\" %%A in ("%full_path%") do (
set "top_level=%%A"
set "second_level=%%B"
)
echo Top level directory: %top_level%
echo Next level directory: %second_level%
Re: i need a batch to find the 1st level of dir name and the 2nd
Posted: 01 Oct 2022 22:15
by nnnmmm
thanks for your help
i needed this code to put a little bit of intelligence to find games
it will reduce a lot of labors to find games,
i can clcik anywhere, any sub dirs or any files, it will find a game to run