Skip to content

Instantly share code, notes, and snippets.

@lue
Created March 12, 2021 21:55
Show Gist options
  • Save lue/c3b481dbc705a604dc7b1e2250ac5c5e to your computer and use it in GitHub Desktop.
Save lue/c3b481dbc705a604dc7b1e2250ac5c5e to your computer and use it in GitHub Desktop.
renaming files for TexturePacker
import glob
import os
curdir = os.getcwd()
dirs = [ name for name in os.listdir('./') if os.path.isdir(os.path.join('./', name)) ]
for j in range(len(dirs)):
os.chdir(curdir)
os.chdir(dirs[j])
f = glob.glob('*')
pref = os.getcwd().split('\\')[-1].split('_')[-1]
for i in range(len(f)):
os.rename(f[i], pref+'_'+str(i)+'.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment