Hi all,
With the below script, I get what I need. The result is a folder name. I need to set e variable to that output/result, and use it in a path to copy a folder from the same batch/script:
"@echo off
setlocal EnableDelayedExpansion
set line=
< file.txt (for /F "delims=:" %%a in (
'findstr /N /C:"Word-to-find" file.txt') do (
set /A skip=%%a-lastLine-1, lastLine=
for /L %%i in (1,1,!skip!) do set /P line=
for /L %%i in (1,1,1) do set /P "line=!line:~14!" & echo/
echo/
))"
Need to use the result/output like this:
"chdir /D %~dp0
xcopy /Y file "%systemdrive%\test\%var%" /E
pause"
Have not been able to set a variable to the above output/result.
If fact what I'm trying to do is:
1) find a string/word in a txt file
2) go 1 line above it
3) get that string minus 14 characters
4) use the output in a path, as it is a folder name. It changes every time
Any help would be much appreciated. Thank you
With the below script, I get what I need. The result is a folder name. I need to set e variable to that output/result, and use it in a path to copy a folder from the same batch/script:
"@echo off
setlocal EnableDelayedExpansion
set line=
< file.txt (for /F "delims=:" %%a in (
'findstr /N /C:"Word-to-find" file.txt') do (
set /A skip=%%a-lastLine-1, lastLine=
for /L %%i in (1,1,!skip!) do set /P line=
for /L %%i in (1,1,1) do set /P "line=!line:~14!" & echo/
echo/
))"
Need to use the result/output like this:
"chdir /D %~dp0
xcopy /Y file "%systemdrive%\test\%var%" /E
pause"
Have not been able to set a variable to the above output/result.
If fact what I'm trying to do is:
1) find a string/word in a txt file
2) go 1 line above it
3) get that string minus 14 characters
4) use the output in a path, as it is a folder name. It changes every time
Any help would be much appreciated. Thank you