Created
February 7, 2011 08:35
-
-
Save sk89q/814146 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import os.path | |
from glob import glob | |
fn_regex = re.compile(r"^c\.(\-?[a-z0-9]+)\.(\-?[a-z0-9]+)\.dat") | |
total = 0 | |
to_delete = 0 | |
for f in glob("world/*/*/c.*.dat"): | |
m = fn_regex.match(os.path.basename(f)) | |
if m: | |
total = total + 1 | |
x = int(m.group(1), 36) | |
y = int(m.group(2), 36) | |
if x * 16 < -1263: # Change x,y here | |
to_delete = to_delete + 1 | |
os.remove(f) | |
print "%s,%s" % (x, y) | |
print "Deleting %d/%d (%.2f%%)" % (to_delete, total, to_delete / float(total) * 100) |
if x * 16 < -1000 or x * 16 > 1000 or y * 16 < -1000 or y * 16 > 1000:
Oh, I'd remove os.remove(f) and have it do a dry run first, just in case.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for this. Unfortunately I am not really knowledgable in python. Given the risks of faulty deletions (yeah I know I have to backup the map anyhow) it would be great to make this foolproof for use.
Questions:
What do I change to delete all coordinates
it looks to me to change line 16 to the respective number and the x to y, but do I have to change the < to > if the number is positive too?
Command line parameters would be great here!