Created
November 1, 2021 06:27
-
-
Save wokoman/6f54f51b9a9eefbeb93841d6741fc615 to your computer and use it in GitHub Desktop.
Script to move photos into folder per their time-stamped name
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
""" | |
Simple script that moves files to folders accordingly to their name. Files must start with YYYYMM format. | |
Useful for old automatic media uploads by OneDrive iOS app (aka SkyDrive). | |
""" | |
import os | |
import shutil | |
from pathlib import Path | |
directory = '/path/to/files/' | |
for file in os.listdir(directory): | |
if "." in file: | |
Path(directory + str(file)[:4] + "/" + str(file)[4:6]).mkdir(parents=True, exist_ok=True) | |
shutil.move(directory + file, directory + str(file)[:4] + "/" + str(file)[4:6] + "/" + file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment