0

I have this simple bat file that I use for copying the files I'm working on to the folder it need to be fur production:

set targetFolder=C:\AppInstall\Blender\MyScripts\addons

set inputFiles[0]=convert_Rotation_Mode.py
:: set inputFiles[1]="example_file.ext"
:: set inputFiles[2]="example folder"

(for %%a in ("%inputFiles%") do ( 
   xcopy /y /e %%a "%targetFolder%"
))

pause

It used to work, but not anymore.

Here's the console output:

>set targetFolder=C:\AppInstall\Blender\MyScripts\addons

>set inputFiles[0]=convert_Rotation_Mode.py

>(for %a in ("") do (xcopy /y /e %a "C:\AppInstall\Blender\MyScripts\addons" ) )

>(xcopy /y /e "" "C:\AppInstall\Blender\MyScripts\addons" )
Invalid drive specification
0 File(s) copied

>pause
Press any key to continue . . .

It looks like unputFile[0] doesn't work for some reason.

I also tried the following in the cmd:

>set a[0]=aaaa

>echo %a%
%a%
L0Lock
  • 147
  • 13
  • 1
    There is no such thing as an array in batch. It's a bunch of independent variables with similar names. Your example just can't "used to work". `for /f "delims=" %%a in ('set inputFiles[') do ...` will work, but will sort the variables as strings (0,1,10,11,...19,2,20,21...) – Stephan Apr 08 '23 at 21:02
  • Then how does this work? [Batch Script - Arrays](https://www.tutorialspoint.com/batch_script/batch_script_arrays.htm) – L0Lock Apr 08 '23 at 21:51
  • 2
    That's a collection of variables that all happen to have the same prefix. There is no `inputFiles` object because batch does not have objects. The closest part of that page to what you want is the "Iterating Over an Array" section with the `for /L` loop. – SomethingDark Apr 08 '23 at 22:23
  • 1
    I suggest you to review [this answer](https://stackoverflow.com/questions/10166386/arrays-linked-lists-and-other-data-structures-in-cmd-exe-batch-script/10167990#10167990) – Aacini Apr 10 '23 at 17:54

0 Answers0