Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, sys
- def convert(path):
- try:
- files_dirs = os.listdir(path)
- files_only = [ i for i in files_dirs if not os.path.isdir(i)]
- py_files = [i for i in files_only if i.endswith('.py')]
- print('found py files: ', py_files)
- print('[...] converting files ...')
- os.chdir(path)
- for file in py_files:
- convert_formula = file[:-3] + '.txt'
- print('converting: ', file)
- os.rename(file, convert_formula)
- print('[+] Done')
- except FileNotFoundError:
- print('[-] invalid path ! ')
- convert(sys.argv[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement