Skip to content

Instantly share code, notes, and snippets.

@ashwch
Created February 11, 2013 18:21
Show Gist options
  • Select an option

  • Save ashwch/4756378 to your computer and use it in GitHub Desktop.

Select an option

Save ashwch/4756378 to your computer and use it in GitHub Desktop.
File Copier ( Distributed Systems Lab)
"""
Program to copy the content of one file to another.
"""
def file_try():
filename =raw_input("Enter the name of the file: ")
try:
open(filename)
return filename
except:
print "File {0} not found or maybe you don't have enough permissions, Try Again!".format(filename)
return file_try()
if __name__ =='__main__':
file_read=file_try()
if file_read:
file_new=raw_input("Enter the name of the new file: ")
with open(file_read) as f1,open(file_new,'w') as f2:
for line in f1:
f2.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment