Copying Files
January 31, 2018
Learning how to copy files with Python. The script also checks the file size in bytes.
from sys import argv
from os.path import exists
script, from_file, to_file = argv
print "Let's copy from %s to %s." % (from_file, to_file)
in_file = open(from_file)
indata = in_file.read()
print "The size is %s bytes in length." % len(indata);
print "Does the target file exist? %r" % exists (to_file)
raw_input()
out_file = open(to_file, 'w')
out_file.write(indata)
in_file.close()
out_file.close()
print "All done."
Recent Entries
- Filter First, Think Later February 21, 2026
- Five Hundred Bugs That Fuzzers Missed February 20, 2026
- Gemini 3.1 Pro and the 0.1 That Matters February 19, 2026