I have a directory full of files I am trying to findstr and extract whats inside the quotes
my test
G:\Games\Steam\steamapps\common\XXXXXXXXX\addons>findstr addontitle workshop\*.vpk
workshop\XXXXXXXXX.vpk: addontitle "Addon 1"
workshop\XXXXXXXX.vpk: addontitle "Addon 2"
-cont-
I just want to have the title only
for /f tokens^=1-3delims^=:^" %%i in ('findstr /RC:"addontitle *\".*\"" "workshop\*.vpk"') do (
echo "FOUND: %%~ni.vpk TITLE: %%k"
mkdir "custom\%%~ni">nul 2>&1
mklink ".\custom\%%~ni\pak01_dir.vpk" "..\..\workshop\%%~ni.vpk">nul 2>&1
echo Game "left4dead2\addons\custom\%%~ni" // %%k>> %GAMEINFO%
)
for /f tokens^=1-3delims^=:^" %%i in ('findstr /VRC:"addontitle *\".*\"" "workshop\*.vpk"') do (
echo "FOUND: %%~ni.vpk"
mkdir "custom\%%~ni">nul 2>&1
mklink ".\custom\%%~ni\pak01_dir.vpk" "..\..\workshop\%%~ni.vpk">nul 2>&1
echo Game "left4dead2\addons\custom\%%~ni" // ADDON INFO MISSING>> output.txt
)
How about this?
@echo off
for /f tokens^=1-3delims^=:^" %%i in ('findstr /RC:"addontitle *\".*\"" "workshop\*.vpk"') do (
mkdir "custom\%%~ni">nul 2>&1
mklink ".\custom\%%~ni\pak01_dir.vpk" "..\..\workshop\%%~ni.vpk">nul 2>&1
echo Game "XXXXXXXX\addons\custom\%%~ni" // %%k
)>> output.txt
findstr
gets the name of the file anyway when used on list of files, so just use that.
Note I took the liberty of adding double quotes to the string echo
ed "XXXXXXXX\addons\custom\%%~ni"
if you do not need it, just remove it.
In the event that addontitle
can be in any case, add /I
to the findstr
command.
@echo off
for /f tokens^=1-3delims^=:^" %%i in ('findstr /IRC:"addontitle *\".*\"" "workshop\*.vpk"') do (
mkdir "custom\%%~ni">nul 2>&1
mklink ".\custom\%%~ni\pak01_dir.vpk" "..\..\workshop\%%~ni.vpk">nul 2>&1
echo Game "XXXXXXXX\addons\custom\%%~ni" // %%k
)>> output.txt