I created a script in order to move modified or new files from one folder to another. When running it, it displays no errors and works fine. Yet no files had moved. Why is this happening?
import os
from shutil import move
from time import time
def mins_since_mod(fname):
"""Return time from last modification in minutes"""
return (time() - os.path.getmtime(fname)) / 60
PARENT_DIR = 'C:\Users\Student\Desktop\FolderA'
MOVE_DIR = 'C:\Users\Student\Desktop\FolderB'
# Loop over files in PARENT_DIR
for fname in os.listdir(PARENT_DIR):
# If the file is a directory and was modified in last 15 minutes
if os.path.isdir(fname) and mins_since_mod(fname) < 15:
move(fname, MOVE_DIR) # move it to a new location