I tried the following code:
set target = "%~dp0\Backup1"
set /s checktarget = %1
for %%I in (%*) do (
if "%checktarget:~0,3%" == "tg." (
set target = %checktarget:~4:3%
) else ( echo "%%I to %target%" )
)
My goal was to check if the first parameter is a destination for a backup.
The destination is supposed to come with a "tg.", followed by a directory.
I run my script with:
test.bat tg.target B1 B2 B3
But when i run this, the output is:
"tg.target to "
"B1 to "
"B2 to "
"B3 to "
What i want it to be is:
"B1 to target"
"B2 to target"
"B3 to target"
I've tried looking for a way to fix this for several hours now. Does anyone know why it just gives me "" as a target? It doesn't even use the target thats set as a default.