Renaming A File | Development | Online Course With Appy Pie Academy

Renaming a file

Lesson Details:
June 29, 2020


I: Introduction (1-2 sentences)

Python is a programming language that was developed by Guido van Rossum. It is known as a high-level programming language because it uses English like statements to create programs. This makes it easier for users to read and understand the code. Python is an open source and interpreted language and is therefore, free.

II: Body (5-7 sentences)

A: Renaming a file (1-2 sentences)

This program renames a file based on the input from the user. The input is stored as a variable called input. The input is then run through a match function match(). If the input matches the name of the file, then the program prints out “Name Matches!!” Otherwise, it prints out “Name does not match!!” The name of the file is then sent into a lambda function lambda x: print(match(input, x) and if the output is True, it will print “Name Matches!!”. Otherwise it will write “Name does not match!!”. Lastly, the filename is changed to be one more than the last filename.

B: Renaming a directory (1 sentence)

This program allows you to rename a directory based on information from the user. It does this by first storing the file name in a variable called newname. It then sends that into a lambda function that matches it against the name of all of the files within that directory. If a match is found, it writes “New File Name Matches!!” and it will change the name of the directory to be one more than the last filename. If there is no match, it writes “New File Name Does Not Match!!” and will print out “New Directory Name Does Not Match!!!”

III: Conclusion (1-2 sentences)

I hope you liked learning about python programming language in my article. I hope you know how to rename files in python now!

loader
Course content