Skip to content

Instantly share code, notes, and snippets.

@glittershark
Created November 1, 2013 00:53
Show Gist options
  • Save glittershark/7259586 to your computer and use it in GitHub Desktop.
Save glittershark/7259586 to your computer and use it in GitHub Desktop.
Intentionally terrible script made for an interview. The subject is asked to fix the script up, and add the functionality for the user to specify a specific file extension to copy.
import os
for index_variable in range(len(os.listdir('.'))):
if os.listdir('.')[index_variable][os.listdir('.')[index_variable].find('.'):] == '.txt':
print "found text file"
import shutil
import sys
shutil.copyfile('./' + os.listdir('.')[index_variable], sys.argv[1] + '/' + os.listdir('.')[index_variable])
for i in range(len(sys.argv) - 2):
if sys.argv[i + 2] == '--and':
shutil.copyfile('.' + os.listdir('.')[index_variable], sys.argv[i + 3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment