Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # All perpose file converter
- # Bobby Clarke 2012
- # GNU General Public License 3.0
- import easygui
- import sys
- import os
- def removeExtention(filename):
- newname = ""
- for char in filename:
- if char == ".":
- break
- else:
- newname += char
- return newname
- def get_dir(files = True):
- """Get the directory the program is in, have True as a parameter to get a list of the files within said directory"""
- selfdir = os.path.dirname(sys.argv[0])
- if files:
- return os.listdir(selfdir)
- else:
- return selfdir
- def convert(filename, newExtention):
- file = open(filename , "rb")
- writefile = open(removeExtention(filename) + newExtention, "wb")
- writefile.write(file.read())
- file.close()
- writefile.close()
- def main():
- question = "Which file do you wish to covert?"
- title = "Universal File Converter"
- newExtention = ""
- filename = easygui.choicebox(question, title, get_dir())
- if filename is None:
- sys.exit()
- while not newExtention:
- newExtention = easygui.enterbox("New file extention (eg .png, .txt)")
- if newExtention is None:
- sys.exit()
- convert(filename, newExtention)
- if __name__ == "__main__":
- main()
Add Comment
Please, Sign In to add comment