Jump to content

Find Clones script


Aetron

Recommended Posts

Posted

Hi, 

frind of mine made a little script to tag clones in an xml where the tag is missing. 

I testest it with MSX 2 and it works quit well. 

Beware its for linux and zsh. 

 

#!/bin/zsh

game1="foobar"
game2=""
setclone=0

cat "$1"| while read line; do
  if [[ "$line" != *"cloneof"* ]] && echo "$line"

  if [[ "$line" == *"game name"* ]]; then
    game2="$(echo "$line" | awk -F"\"" '{print $2}')"
    if [[ "$game2" == "$game1"* ]]; then
      setclone=1
    else
      game1="$game2"
    fi
  fi

  if [[ "$line" == *"cloneof"* ]]; then
    if [ $setclone -eq 1 ]; then
      echo "<cloneof>$game1</cloneof>"
      setclone=0
    else
      echo "<cloneof></cloneof>"
    fi
  fi
done

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...