I would like to know how to change the name of the file from '001.txt' to 'Hong Gil-dong-001.txt' or 'Im Kkeok-jeong-001.txt' freely.
When there is a file named 001.txt
When the character 'Hong Gil-dong' is input through the input command, it changes to the name 'Hong Gil-dong-001.txt'.
I want to make a program that changes to the name of Lim Kkeokjeong-001.txt when I receive the text 'Im Kkeokjeong'.
I know I have to use the name, but I don't know how to change it to a name I want at that time, not a fixed name.
rename file-name python
import os
filename = '001.txt'
prefix = input()
os.rename(filename, prefix + '-' + filename)
© 2024 OneMinuteCode. All rights reserved.