Created
June 12, 2025 17:23
-
-
Save aslamanver/df9ce726065f570bd22830a6fd34c652 to your computer and use it in GitHub Desktop.
Simpler script to move files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
from typing import Callable | |
def move_files(condition: Callable[[str], bool], source_path: str, destination_path: str): | |
os.makedirs(destination_path, exist_ok=True) | |
for filename in os.listdir(source_path): | |
if condition(filename): | |
source = os.path.join(source_path, filename) | |
destination = os.path.join(destination_path, filename) | |
shutil.move(source, destination) | |
print(f"Moved: {filename} to {destination_path}") | |
if __name__ == "__main__": | |
move_files( | |
condition = lambda filename: | |
filename.startswith("Simulator Screen Recording") and | |
filename.lower().endswith(('.png', '.jpg', '.jpeg', '.gif', '.mp4')), | |
source_path = "/Users/Aslam/Desktop/Screenshots", | |
destination_path = "/Users/Aslam/Desktop/Simulator Screen Recordings" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment