Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
tms2xyz.sh
#!/bin/bash
# rename TMS tiles to the XYZ schema
# no quoting, since all files have simple numeric names
# do not run this anywhere else than INSIDE your tiles directory
# run it like this: find . -name "*.png" -exec ./tms2xyz.sh {} \;
filename=$1
tmp=${filename#*/} # remove to first /
z=${tmp%%/*} # remove from first /
tmp=${filename%/*} # remove from last /
x=${tmp##*/} # remove to last /
tmp=${filename##*/} # remove to last /
y=${tmp%.*} # remove from first .
extension=${filename##*.}
let newy="2**$z-$y-1" # calculate the xyz tile
#echo $z $x $y $newy $extension
# remove the echo if you are sure you want to do this
echo mv ${filename} ./$z/$x/$newy.$extension
@andrewharvey

This comment has been minimized.

Copy link

andrewharvey commented Apr 17, 2018

I needed to run it like this: find . -name "*.png" -exec ./tms2xyz.sh '{}' \;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.