0

I'm doing a batch script to get some anime, I call livestreamer for that task. I'm trying to use this script

@echo off
@set name=aldnoah
@set num=0
@set plus=1
@set fullname=%nombre%%numero%
for /F "tokens=*" %A in (aldnoah.txt) do livestreamer %A best -o %fullname%.mp4 && set /a num=%num%+1
pause

It will say "Wasn't expecting A that moment", but if I instead go to cmd and run " for /F "tokens=*" %A in (aldnoah.txt) do livestreamer %A best -o %fullname%.mp4" it'll work fine, starting the download. Not sure where does it fail... Thanks!

Forgot to add the example url

http://www.crunchyroll.com/aldnoahzero/episode-1-princess-of-vers-656657

It's not that it's got any ampersand on it.

Adding that, if anyone interested in this piece of batch, here I leave the fixed .bat

 @echo off
set name=aldnoah
set number=1
set fullname=%name%!number!
SETLOCAL EnableDelayedExpansion
for /F "tokens=*" %%A in (aldnoah.txt) do livestreamer %%A best -o %fullname%.mp4 && echo Finished downloading %fullname% && set /a number=!number! + 1
ENDLOCAL
echo fi
pause

Replace aldnoah.txt for any txt containing Crunchyroll links for your anime, and it'll autocount the chapters.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
Angel S.
  • 3
  • 3
  • in batchfiles you have to double the percentsigns for the `for`-variables: `%%A` instead of `%A`. Also are you sure, you didn't mix any variablenames? You use two variables that you didn't declare before. Also take a look at [delayed expansion](http://stackoverflow.com/a/30284028/2152082) – Stephan Oct 01 '15 at 09:08
  • Yeah, it was the %% thing, thanks! – Angel S. Oct 01 '15 at 09:12
  • This is also clearly indicated in the help text of `for` -- type `for /?` in command prompt... – aschipfl Oct 01 '15 at 13:51

1 Answers1

1

%A will definitely work on CMD, but only on the console. If you're running the script from a .bat file, change it to %%A.

Happy Face
  • 1,061
  • 7
  • 18