-1

Good day. I'm trying to write a Windows batch file to backup photos from my drive E: to drives H: and J: while creating a separate log file for each backup operation. I thought that this would be a good time to learn about FOR loops. So far I have:

for %%s in (h, j) do (
echo Backing up to: %%s
set %%BuLog%%=filenane-%%s.log
echo %BuLog%
)

With the set statement I am trying to create a filename for the log file. The above does not work. It wants to create the same filename in booth passes. I am looking for 'filename-h.log' and 'filename-j.log.

I have tried different arrangements of % and %%, quoting, mild swears, and Googling. Thanks!

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • [Variables are not behaving as expected](https://stackoverflow.com/questions/30282784/variables-are-not-behaving-as-expected) probably #1 FAQ. – Magoo Aug 08 '23 at 03:53
  • What are you trying to do with `set %%var%%`? It should probably be `set "BuLog=filename-%%s.log" (and of course delayed expansion to *use* this variable. – Stephan Aug 08 '23 at 06:25

0 Answers0