Created
November 1, 2013 00:53
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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