<div class="asd">
<div data-atr="./img/pic.png"></div>
</div>
<div class="asd">
<div data-atr="./img/pic2.png"></div>
</div>
<div class="asd">
<div data-atr="./img/pic.png" style="./img/pic.png"></div>
</div>
<div class="asd">
<div data-atr="./img/pic2.png" style="./img/pic2.png"></div>
</div>
const elements = document.querySelectorAll('div[data-atr]')
elements.forEach(elem => elem.style = elem.dataset.atr);