rename_dir.py 693 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. '''
  4. @Contact : liuyuqi.gov@msn.cn
  5. @Time : 2024/02/02 16:39:55
  6. @License : Copyright © 2017-2022 liuyuqi. All Rights Reserved.
  7. @Desc : rename dir spring-boot to springboot
  8. '''
  9. import os,sys,re
  10. workdir= os.getcwd()
  11. def run():
  12. for root, dirs, files in os.walk(workdir):
  13. for dir in dirs:
  14. if dir.startswith('spring-boot'):
  15. #rename dir
  16. newdir = dir.replace('spring-boot','springboot')
  17. os.rename(os.path.join(root,dir), os.path.join(root, newdir))
  18. else:
  19. print("sss")
  20. pass
  21. if __name__=='__main__':
  22. run()