Writing a javascript array using a batch file
Many times we want to write out an array of images from a directory when making up a javascript. This batch file will do it for you on most modern computers, helpful if many images are involved:
Code:
@echo off
if '%1'=='w' (
echo array_name[%i%]='path%2'; >> array_it.js
set /a i=i+1
) else (
echo array_name=[]; > array_it.js
set /a i=0
for %%p in (*.jpg, *.gif, *.png) do (
call make_array.bat w %%p
)
set i
set i=
)
If you wish to have a path to the files included in each array entry, change path in the above to the desired path. Otherwise, delete it. Save as a plain text file and name it make_array.bat - When run in a folder containing image files, it will make a file in that folder named array_it.js containing the array array_name.