Answering my own question. I will start a new thread with full usage
#!/bin/bash # Script use $ sudo ./makexml.sh [RomDirectoryName] [-n optional] # -n does not right name to <name> tag useful for MAME roms as ES will autofill correct name # Store arguments arg1=$1 arg2=$2 output="gamelist.xml" # Change deliminator for $IFS # Allows script to work with names with white space SAVEIFS=$IFS IFS=$(echo -en "\n\b") # print scripts current status printf "Scanning dir: "$arg1"...\n" # Creates output XML file (gamelist.xml) printf "<?xml version=\"1.0\"?>\n\n" > ./$arg1/$output printf "<gameList>\n" >> ./$arg1/$output # Scans directory given by first argument for file in ./$arg1/* do # Just some manipulatiuon of data returned by $file filename=$(echo $file | cut -f 3 -d '/') name=$(echo $filename | cut -f 1 -d '.') # Checking for existance of correctly named image in ./images dir. [[ -f ./$arg1/images/$name.png ]] && theImage=./images/$name.png || theImage="" # Start writing to gamelist.xml printf "\n" >> ./$arg1/$output printf "\t<game>\n" >> ./$arg1/$output printf "\t\t<path>./"$filename"</path>\n" >> ./$arg1/$output # Checking whether the -n argument was used if [ $arg2 = "-n" ]; then name="" fi # Continuing writing to gamelist.xml printf "\t\t<name>"$name"</name>\n" >> ./$arg1/$output printf "\t\t<desc></desc>\n" >> ./$arg1/$output printf "\t\t<image>"$theImage"</image>\n" >> ./$arg1/$output printf "\t\t<rating></rating>\n" >> ./$arg1/$output printf "\t\t<releasedate></releasedate>\n" >> ./$arg1/$output printf "\t\t<developer></developer>\n" >> ./$arg1/$output printf "\t\t<publisher></publisher>\n" >> ./$arg1/$output printf "\t\t<genre></genre>\n" >> ./$arg1/$output printf "\t\t<players></players>\n" >> ./$arg1/$output printf "\t</game>\n" >> ./$arg1/$output # Print scripts current status printf $filename clear printf "Scanning dir: "$arg1"...\n" done # Closing gamelist.xml file printf "</gameList>" >> ./$arg1/$output # print scripts current status clear printf "Finished\n"Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.