I have created a batch command to download (using wget) some files from a specific site.... on my fist version i have myself created a multi prompt request and only when you put a empty value there's start to download all previously input.
This is how i created:
Code: Select all
@ECHO OFF
CLS
SETLOCAL EnableDelayedExpansion
REM Variabili
SET User=My access on site
SET Pass=obviously my pass
SET UserAgent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
SET Link_Base=https://bda.retroroms.info/downloads/mame/currentroms/
REM Nomi Downloads
:START
ECHO.
ECHO Inserire Nome/i Roms (VUOTO per iniziare i/il Downloads):
:NEXT
REM SET /P File%num% = %num%.
FOR /L %%A IN (1,1,100) DO (
SET /P File[%%A]=%%A.
IF [!File[%%A]!]==[] GOTO DOWNLOAD
)
:DOWNLOAD
FOR /L %%A IN (1,1,100) DO (
IF [!File[%%A]!]==[] GOTO OUT
SET Cmd=wget --user=%User% --password=%Pass% --user-agent="%UserAgent%" "%Link_Base%!File[%%A]!.zip"
ECHO !Cmd!
ECHO.
!Cmd!
CHOICE /C:AB /T:5 /D:A >NUL
)
:OUT
I have to set the limit to 100 because this site whit a "normal account" has a limit download...... 100 files for every 24hours
At this point i have another idea to create a different batch....... a totally news batch can be read all files name from a TXT files and after that need to start download.
I have start to "develop" it last night whitout success.......... i need some helps whit for command..... that's is all i have already write:
Code: Select all
@ECHO OFF
CLS
SETLOCAL EnableDelayedExpansion
SET User=Myuser
SET Pass=Mypass
SET UserAgent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
SET Link_Base=https://bda.retroroms.info/downloads/mame/currentroms/
REM Nome File TXT da Leggere
:LOOP1
ECHO.
SET /P FileTXT=Inserire Nome File TXT:
IF [%FileTXT%]==[] (
ECHO File non valido
GOTO LOOP1
)
IF EXIST .\%FileTXT% (
GOTO OK1
) ELSE (
ECHO File non trovato...
GOTO LOOP1
)
:OK1
REM Inizio Lettura FileTXT
FOR /F "skip=1" %%A IN (.\%FileTXT%) DO (
SET File[%%A]=%%A.zip
)
Apparently whit this i can read the txt files but it's my idea to be obtain every variable for every line....... it's not possible ?
If i add a "ECHO !%File[%%A]%!" after the set i can see on screen all lines on txt whit correctly .zip at ends.... but apparently i can't read a specific line, i have tryed to "echo" the variable "50" and there's no works..
Someone can me some sugggestion ? Thanks in advance..........
*EDIT nm.1*
In this last night and about in this last hours i have made some TEST on this........... apparently after a various and various "Google search" i have found and made a working version of this batch.... i thinks i can post how i obtain:
Code: Select all
@ECHO OFF
CLS
SETLOCAL EnableDelayedExpansion
SET L=0
SET User=My User
SET Pass=MyPassword
SET UserAgent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
SET Link_Base=https://bda.retroroms.info/downloads/mame/currentroms/
REM Nome File TXT da Leggere
:LOOP1
ECHO.
SET /P FileTXT=Inserire Nome File TXT:
IF [%FileTXT%]==[] (
ECHO File non valido
GOTO LOOP1
)
IF EXIST .\%FileTXT% (
GOTO OK1
) ELSE (
ECHO File non trovato...
GOTO LOOP1
)
:OK1
REM Inizio Lettura FileTXT
for /f "usebackq tokens=*" %%A in (".\%FileTXT%") do (
set /a L += 1
set "File!L!=%%A.zip"
)
REM Conferma dei File da Scaricare
CLS
ECHO.
ECHO Lista dei File da scaricare:
FOR /L %%A IN (1,1,100) DO (
ECHO %%A. !File%%A!
IF [!File%%A!]==[] GOTO OUT1
)
:OUT1
ECHO Confermare l'avvio dei download (S/N) ?
CHOICE /C:SN
IF %ERRORLEVEL% EQU 2 GOTO EXIT
IF %ERRORLEVEL% EQU 1 GOTO DOWNLOAD
:DOWNLOAD
REM Inizio dei Download
CLS
FOR /L %%A IN (1,1,100) DO (
SET Cmd=wget --user=%User% --password=%Pass% --user-agent="%UserAgent%" "%Link_Base%!File%%A!"
ECHO Download File %%A:
ECHO !Cmd!
ECHO.
!Cmd!
CHOICE /C:AB /T:5 /D:A >NUL
IF [!File%%A!]==[] GOTO OUT2
)
:OUT2
:EXIT
Code: Select all
:OK1
REM Inizio Lettura FileTXT
for /f "usebackq tokens=*" %%A in (".\%FileTXT%") do (
set /a L += 1
set "File!L!=%%A.zip"
)
After that for another FOR /L i have pick the fist 100 variable (Becuase remember....... the daily download it's limited at 100 whit a normal account)....... and ask to user if want to start download or not.
Another after that....... i have start the download using wget......... another FOR /L for all download.
In the both loop you can also found a if condition....... it's need if the txt contain less of 100 line....... this will need to not set EMPTY variable........ apparently there's works.
At this my condition....... i don't know if the BEST way to obtain my result. For Example....... it's possibly directly to extract only the first 100 line directly and set only the first 100 variable from txt ? I don't know how it's possible....... if someone can.... please explain.
Another question......... on actually batch all .zip it's be download in same location when it's placed the wget.exe and the all .batch and it's a lot of confusion to pick all .zip files....... i thinks it's an idea to add a path folder on wget.......