Last active
March 1, 2020 13:48
-
-
Save Roumenov/ba15934055c4365c1437faf02a2db411 to your computer and use it in GitHub Desktop.
primitive procedure to rename a bunch of files that broke with naming convention
This file contains hidden or 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
import shutil, os | |
current_directory = os.getcwd() | |
filename = 'output.txt' | |
for file in os.listdir(current_directory): | |
active = file.replace('_idle', '_act') | |
print(active) | |
if '_idle' in file and not os.path.isfile(active): | |
output = file.replace('_idle','_act') | |
source = file.replace('_idle','') | |
with open(filename, 'a') as f: | |
f.write(output) | |
f.write(",\n") | |
if os.path.isfile(source): | |
shutil.copy(source, active) | |
else: | |
pass | |
shutil.copy(file,source) | |
os.remove(file) | |
else: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment