I am trying to write this program to read through directories into the file and read the first line of the file. If it finds certain keywords to then re name the file, copy the file, and more it to a corresponding directory.
import os
import shutil
import sys
os.chdir('c:\\source')
sourcePattern = '2:I103'
targetDirMt = 'mt'
targetDirF21 = 'F21'
curFile = open(os.path.abspath(os.curdir) + '\\' +'ack_nak', 'r+')
for line in fileinput.input ( curFile ): #(os.curdir, 'r+')
if sourcePattern in curFile :
os.rename(file, '2:I103-'+file)
if targetDirMt in curFile :
shutil.move(file,'C:\\target\\mt')
if targetDirF21 in curFile :
shutil.move(file,'C:\\target\\F21')
Why do I get this??
Traceback (most recent call last):
File "C:\Python34\project1.py", line 12, in <module>
curFile = open(os.path.abspath(os.curdir) + '\\' +'ack_nak', 'r+')
PermissionError: [Errno 13] Permission denied: 'c:\\source\\ack_nak'