Ambushes
Ambushes

Reputation: 53

Windows Batch won't let me break long "FOR" loop into multiple lines?

FOR /F %a in (downloadlist.txt) DO (
SET url=%a
&& SET suffix=%url:ftp://ftp.ncbi.nlm.nih.gov/genomes/all=% 
&& SET combined=%url%%suffix%
&& SET a_link=%combined%%assembly%
&& echo %a_link%
&& SET t_link=%combined%%transcripts%
&& SET cds_link=%combined%%CDS%
&& SET p_link=%combined%%protein%
&& WGET %a_link%
&& WGET %t_link%
&& WGET %cds_link%
&& WGET %p_link%
)

How can i break this up into multiple lines? This is what I have currently and it doesn't work. I've also tried using the ^ character. What am I doing wrong?

Upvotes: 0

Views: 301

Answers (1)

sambul35
sambul35

Reputation: 1098

Replace unknown variable values assembly, transcripts, CDS, protein with your real values, save this script to a file test.bat and run it from Cmd window. Post exact error message if any.

@echo off
setlocal enabledelayedexpansion
set "assembly=1" & set "transcripts=2" & set "CDS=3" & set "protein=4"
FOR /F %%a in (downloadlist.txt) DO (
    SET url=%%a
    SET suffix=!url:ftp://ftp.ncbi.nlm.nih.gov/genomes/all=!
    SET combined=!url!!suffix!
    SET a_link=!combined!%assembly%
    echo !a_link!
    SET t_link=!combined!%transcripts%
    SET cds_link=!combined!%CDS%
    SET p_link=!combined!%protein%
    WGET !a_link! && WGET !t_link! && WGET !cds_link! && WGET !p_link!
)
exit /b

Upvotes: 1

Related Questions