Last active
November 7, 2021 04:25
-
-
Save nalaekaw/1adf6c56ea60ad1f6af091fe38286cb1 to your computer and use it in GitHub Desktop.
Tool for remaming files using python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rename files in folder | |
import os, time | |
folder = "./" | |
search_for = "file" | |
replace_to = "test" | |
time.sleep(2) | |
with os.scandir(path=folder) as it: | |
for entry in it: | |
if entry.is_file(): | |
print(entry.name) | |
new_name = entry.name.replace( | |
search_for, replace_to) | |
print(new_name) | |
os.system("mv \"" + | |
folder + entry.name + | |
"\" \"" + new_name + | |
"\"") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment