Continusly to How can i move files from one directory to another? i try to move all jpg files from folder r"C:\Project\layers" to folder r"C:\Project\layers\new" with this code, but i get en error:
import shutil, os
source = r"C:\Project\layers"
destination = r"C:\Project\layers\new"
if not os.path.exists(destination):
os.makedirs(destination)
for f in os.listdir(source):
if f.endswith(".jpg"):
shutil.move(source + f, destination)
the error:
Traceback (most recent call last):
File "C:\Users\yaron.KAYAMOT\Desktop\python.py", line 8, in <module>
shutil.move(source + f, destination) # add source dir to filename
File "C:\Python27\ArcGISx6410.3\lib\shutil.py", line 302, in move
copy2(src, real_dst)
File "C:\Python27\ArcGISx6410.3\lib\shutil.py", line 130, in copy2
copyfile(src, dst)
File "C:\Python27\ArcGISx6410.3\lib\shutil.py", line 82, in copyfile
with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: 'C:\\Project\\layerslogo1.jpg'
>>>