Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import os
- # Constants
- FILES_IN_DIR = os.listdir()
- # Functions
- def getInput():
- source = ""
- print("Options: ")
- for i in FILES_IN_DIR:
- print(i)
- print('\n')
- while source not in FILES_IN_DIR:
- source = input("Please enter the name of the source file: ")
- return source
- def findExtension(source):
- return source.find('.')
- def getSourceInfo(source):
- f=open(source, "r")
- sourceInfo = f.read()
- f.close()
- srcInfo = [source[:findExtension(source)-1:-1], sourceInfo]
- return srcInfo
- def createNewFile(srcInfo):
- newFileName = input("Please enter the name of the new file: ")
- f=open((newFileName+srcInfo[0][::-1]),"w")
- f.write(srcInfo[1])
- f.close()
- def main():
- createNewFile(getSourceInfo(getInput()))
- # Running the Program
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement