The best way to Transfer Information From One Listing to One other Utilizing Python

If it is advisable transfer information from one listing to a different listing, utilizing Python, then you are able to do one of many following:

Possibility 1 – Utilizing shutil.transfer()#

import shutil
import os
 
file_source = 'supply/listing'
file_destination = 'vacation spot/listing'
 
get_files = os.listdir(file_source)
 
for file in get_files:
    shutil.transfer(file_source + file, file_destination)

Possibility 2 – Utilizing os.exchange()#

import os
 
file_source = 'supply/listing'
file_destination = 'vacation spot/listing'
 
get_files = os.listdir(file_source)
 
for file in get_files:
    os.exchange(file_source + file, file_destination + file)

Possibility 3 – Utilizing pathlib#

from pathlib import Path
import shutil
import os

file_source ='supply/listing'
file_destination ='vacation spot/listing'

for file in Path(file_source).glob('some_file.txt'):
    shutil.transfer(os.path.be part of(file_source,file), file_destination)