Hacking TPL converter script

CalebW

Fellow Temper
OP
Member
Joined
Jun 29, 2012
Messages
638
Trophies
0
Location
Texas
XP
545
Country
United States
I'm tired of converting .tpls manually one by one so I decided to try to create a bash script(I use Linux not windows) that uses TPL.exe and would convert all .tpls to .png in the folder and vise versa. The script for tpl to png is:

#!/bin/sh
# converts .tpl images to .png

for i in *.tpl; do
if [ -e "$i" ]; then
file=`basename "$i" .tpl`
./TPL.exe "$i" "$file.png"
fi

done

and to convert png to tpl you just replace each file type with its counterpart (tpl changes to png and png changes to tpl) so the script would be:

#!/bin/sh
# converts .png images to .tpl

for i in *.png; do
if [ -e "$i" ]; then
file=`basename "$i" .png`
./TPL.exe "$i" "$file.tpl"
fi

done
 

Wiimm

Developer
Member
Joined
Aug 11, 2009
Messages
2,292
Trophies
1
Location
Germany
Website
wiimmfi.de
XP
1,519
Country
Germany
Code:
for i in *.tpl; do
 if [ -e "$i" ]; then
 file=`basename "$i" .tpl`
 ./TPL.exe "$i" "$file.png"
 fi
done
First, you can write this code smaller:
Code:
for i in *.tpl; do
  [ -e "$i" ] && ./TPL.exe "$i" "${i%.tpl}.png"
done
and if using my szs tools the code becomes smaller again:
Code:
wimgt copy *.tpl %N.png
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Psionic Roshambo @ Psionic Roshambo: https://www.youtube.com/@legolambs