Today I had to automate changing some IDs in Protege.

I’m using Protege for one of my projects involving Semantic web. I started with home made meaningful ids. But it is not really useful, neither really automatable. So I wanted to switch to auto-incremented Ids. I have >400 entities, I didn’t want to make all of them by hand. Timing is crucial to get this to work properly. Maybe having something to check color of pixels would help. But for a 2min effort script, that’s good enough.

echo "Be ready and go to the protege window"
sleep 1
echo "Is that ok?"
sleep 3
echo "I warned you"

xdotool mousemove $X_URI_WINDOW $Y_URI_WINDOW
for i in {0000342..349}
    xdotool key ctrl+u
    sleep 0.4
    xdotool click 1
    sleep 0.05
    xdotool key End
    sleep 0.05
    xdotool key shift+Home
    sleep 0.05
    xdotool type `printf 'CN_%s\n' $i`
    xdotool key Return
    sleep 0.3
    xdotool key Down
    sleep 0.2