forked from VoxeLibre/VoxeLibre
26 lines
642 B
Python
26 lines
642 B
Python
import os
|
|
|
|
def rename_files():
|
|
directory = input("Path: ")
|
|
|
|
if not os.path.isdir(directory):
|
|
print("Could not find the path!")
|
|
return
|
|
|
|
prefix = input("Prefix: ")
|
|
|
|
files = os.listdir(directory)
|
|
|
|
for file in files:
|
|
if os.path.isfile(os.path.join(directory, file)):
|
|
file_name, extension = os.path.splitext(file)
|
|
|
|
if not file_name.startswith(prefix):
|
|
new_file_name = prefix + file_name + extension
|
|
os.rename(os.path.join(directory, file), os.path.join(directory, new_file_name))
|
|
|
|
print("Done!")
|
|
|
|
if __name__ == "__main__":
|
|
rename_files()
|