Advertisement
cmiN

shrink file names

Nov 10th, 2011
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. #! /usr/bin/env python
  2.  
  3. import os
  4. SIZE = 32
  5.  
  6. def main():
  7.     """ Main function, all the work goes here. """
  8.     cnt = 0
  9.     for name in os.listdir(os.getcwd()):
  10.         cnt += 1
  11.         pnt = name.rfind(".")
  12.         ext = name[pnt:]
  13.         new = name[:min(pnt, SIZE)]
  14.         os.rename(name, str(cnt) + new.strip() + ext)
  15.  
  16. if __name__ == "__main__":
  17.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement