Guest User

Untitled

a guest
Apr 25th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. # contains helpful premade actions we'll be using later.
  2. # Anything that starts with os. came from this
  3. import os
  4.  
  5. # gets a list of all the items in the current directory
  6. file_names = os.listdir(".")
  7.  
  8. # we'll loop over every file in the current directory
  9. for file_name in file_names:
  10. # define the prefix we're looking to remove
  11. prefix = "sony_"
  12.  
  13. # if this current file has the prefix we don't want
  14. if prefix in file_name:
  15. # create the new file name without the prefix
  16. new_file_name = file_name[len(prefix):]
  17.  
  18. # print out for improved readability
  19. print(f"renaming {file_name} to {new__file_name}")
  20.  
  21. # perform the actual renaming of the file
  22. os.rename(file_name, new_file_name)
Add Comment
Please, Sign In to add comment