TPL converter script

Discussion in 'Wii - Hacking' started by CalebW, Jan 14, 2013.

  1. CalebW
    OP

    CalebW Fellow Temper

    Member
    634
    154
    Jun 29, 2012
    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
     
  2. Wiimm

    Wiimm Developer

    Member
    2,117
    332
    Aug 11, 2009
    Gambia, The
    Germany
    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