Advertisement
gondimedia

Pyton code - renaming

May 6th, 2020
979
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import shutil
  3. import os
  4. import sys
  5.  
  6. dr = sys.argv[3]
  7.  
  8. for root, dirs, files in os.walk(dr):
  9.     for file in files:
  10.         if file == "index.html":
  11.             spl = root.split("/"); newname = spl[-3]; sup = ("/").join(spl[:-3])
  12.             shutil.move(root+"/"+file, sup+"/"+newname+".html"); shutil.rmtree(root)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement