Windows batch script to determine last folder in list of paths -
i read list of paths file , determine each time last folder. have found something start with, failed, read various threads dealing nested loops , variable expansions without success. not "last folder:" response. seeing problem here? appreciated!
external file (paths.txt):
c:\firstfolder\nextfolder\lastfolder c:\somewhere\deeper\finallythere c:\temp
windows batch script:
@echo off setlocal enabledelayedexpansion /f "tokens=* eol=#" %%f in (%cd%\paths.txt) ( echo new path file: %%f set mydir=%%f set m=%mydir:\=;% call :get_symlink %%m ) setlocal disabledelayedexpansion goto :eof :get_symlink /f "tokens=* delims=;" %%i in (%1) call :last_folder %%i goto :eof :last_folder if "%1"=="" ( echo last folder: %last% goto :eof ) set last=%1 shift goto :last_folder
i afraid not clear result want, if this:
lastfolder finallythere temp
... batch file got it:
@echo off /f %%a in (paths.txt) echo %%~na
for further details, type for /?
, read description "for variable modifiers".
if paths may have spaces, include "delims=" option in way:
for /f "delims=" %%a in (paths.txt) echo %%~na
Comments
Post a Comment