I know there are many other ways to solve a problem like this but i would love to know why this code isn't working..
import shutil
import os # Access to some functions of the operating system
import time
def auto_backup():
source_dir = r'C:\Users\Derma\OneDrive\Desktop\back'
target_dir = r'C:\Users\Derma\OneDrive\Desktop\test'
file_names = os.listdir(source_dir)
while True:
for file_name in file_names:
shutil.move(os.path.join(source_dir, file_name), target_dir)
time.sleep(1)
print("Executed")
auto_backup()
The problem is: The program does the shutil
command but doesn't execute the print
function call. Why?