Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Shell script to populate sample images for array of names
#!/bin/bash
productIds=("5108401" "5108004" "5084002" "084003" "513802" "510724" "1083800" "31083" "313725" "5084224" "82759" "11735" "1104_2" "11268" "133" "11084_2" "114189" "1721" "143" "SA058" "0848_1" "540854" "140876" "34_4" "34068" "584397" "6296" "640008" "09T-IC" "653" "54086" "1903" "3315" "54587" "54527" "B23" "SOF43-TP" )
productImgs=( "productImage.png" "productImage-1.png" "productImage-2.png" "productImage-3.png" "productImage-4.png")
prodLen=${#productIds[@]} #productid array length
imgLen=${#productImgs[@]} #img array length
# use for loop to read all productids
for (( i=0; i<${prodLen}; i++ ));
do
cp "${productImgs[$((RANDOM%imgLen))]}" "ProductImages/${productIds[$i]}.png"
done
echo "Completed generating $prodLen images from $imgLen sample images."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment