Skip to content

Instantly share code, notes, and snippets.

@sysint64
Created March 1, 2017 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sysint64/361c04cfc8412cbc48469db2f702746c to your computer and use it in GitHub Desktop.
Save sysint64/361c04cfc8412cbc48469db2f702746c to your computer and use it in GitHub Desktop.
copy android files with suffixes hdpi, mdpi etc. to folders minimap-hdpi, minimap-mdpi etc. without suffixes.
import glob, os
from shutil import copyfile
suffixes = [
"xxxhdpi",
"xxhdpi",
"xhdpi",
"hdpi",
"mdpi",
]
for filename in glob.glob("*.png"):
copy_filename = None
current_suffix = None
for suffix in suffixes:
p = filename.find(suffix)
if p != -1:
copy_filename = filename[:p] + filename[p+len(suffix):]
current_suffix = suffix
break
if copy_filename is not None:
new_path = "mipmap-"+current_suffix+"/"+copy_filename
print(filename, "->", new_path)
copyfile(filename, new_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment