0
import os
from shutil import copyfile

change to my working directory

os.chdir('Z:/')

confirm my current working directory

print (os.getcwd())

this is the file source I would like to copy

infile = open("NFO.nfo","r")

this reads into "file_nfo" all the "file names" with NFO extension that I am trying to copy using the "shutil.copy" to copy SourceFile > DestinationFile

for f in os.listdir ():
    file_name, file_ext = os.path.splitext(f)
    file_nfo = file_name+'.nfo'
    print (file_nfo)
    shutil.copyfile (infile, file_nfo)

copyfile (infile, outfile) - this is not working - any help is appreciated - I would like to thank you in advance for taking the time to read this.

this closes the SourceFile

infile.close()
0

1 Answer 1

1

infile is a file object, but copyfile() requires file names.

If you want to copy the same source file every time, use the name:

shutil.copyfile ("NFO.nfo", file_nfo)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.