Last active
October 3, 2018 13:12
-
-
Save amlang/0ab5bf29aad0a036417f2009089858bc to your computer and use it in GitHub Desktop.
Move pictures to date sorted folders
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
from __future__ import print_function | |
import os | |
import datetime | |
for file in os.listdir("."): | |
if os.path.isfile(file) and (file.endswith('ARW') or file.endswith('jpg') or file.endswith('JPG') or file.endswith('xmp')) : | |
stat = os.stat(file) | |
created = stat.st_birthtime | |
dt = datetime.datetime.fromtimestamp(tt) | |
year = d.year | |
dirname_year = './%s' % year | |
dirname_storageplace = '%s/%s' % (dirname_year, d.strftime('%Y-%m-%d')) | |
if not os.path.exists(dirname_year): | |
os.mkdir(dirname_year) | |
print('mkdir %s' % dirname_year) | |
if not os.path.exists(dirname_storageplace): | |
os.mkdir(dirname_storageplace) | |
print('mkdir %s' % dirname_storageplace) | |
os.rename(file, '%s/%s' % (dirname_storageplace,file)) | |
print('mv %s %s/%s' % (file, dirname_storageplace, file)) | |
print('done!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment