#!/bin/bash

if [ $# -eq 0 ]
then
    echo "No folder name supplied"
    echo "Usage: filenames.sh path/to_folder"
    echo "The folder should reside in the transport fever mods directory, "
    echo "otherwise, the script will report vanilla assets as missing."
    exit
fi

cd $1

function look_for_file {
    grep -irh "$1" res/ | while read -r line
    do
        fstart="${line#*\"}"
        fpath="${fstart%%\"*}"
        if ! [ -e "$2/$fpath" ] && ! [ -e "../../$2/$fpath" ]
           then
            echo "$2/$fpath"
        fi
    done
}

look_for_file "filename =" "res/textures"
look_for_file ".mtl" "res/models/material"
look_for_file ".msh" "res/models/mesh"
look_for_file ".mdl" "res/models/model"
look_for_file ".grp" "res/models/group"
