metinsaylan // rogue developer

Dos Batch to Organize Photos By Date

Painless organization of your mobile photos by date

I have been using OneDrive photo backups for a while now. And It is a great feature that easily handles all the synchronization across all your devices. There is only one thing that is missing. It doesn’t organize your photos. That’s why I wrote a quick script to do that for me.

Here is the script for anyone interested:

SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
@ECHO OFF

REM Photos directory
SET PhotosDir=%USERPROFILE%\OneDrive\Pictures

REM Uncomment following line if folder is on drive D
REM D:

REM Change to Photos directory
CD %PhotosDir%

FOR /l %%i in (2015,1,2017) DO (
  FOR /l %%j in (1,1,12) DO (
    SET /A mlabel=%%j
    IF !mlabel! LSS 10 ( SET mlabel=0!mlabel!)
    MKDIR %%i-!mlabel!
    MOVE %%i!mlabel!*.jp*g %%i-!mlabel!
    MOVE IMG-%%i!mlabel!*.jp*g %%i-!mlabel!
    MOVE IMG_%%i!mlabel!*.jp*g %%i-!mlabel!
    MOVE IMG_%%i-!mlabel!*.jp*g %%i-!mlabel!
  )
)

REM Move all videos to Videos folder
MKDIR Videos
MOVE *.mp4 Videos

REM Move screenshots to Screenshots folder
MKDIR Screenshots
MOVE Screenshot*.png Screenshots
MOVE Screenshot*.jp*g Screenshots

REM Move office lens documents to OfficeLens folder
MKDIR OfficeLens
MOVE Office*.jp*g OfficeLens

REM Move images saved from facebook to Facebook folder
MKDIR Facebook
MOVE FB_IMG* Facebook

REM Move all images that has wallpaper in file name to Wallpapers folder
MKDIR Wallpapers
MOVE *wallpaper*.jpg Wallpapers

REM Clear empty folders
FOR /f "usebackq delims=" %%d in (`"DIR /ad/b/s | sort /R"`) DO RD "%%d"

CLS
ECHO.
ECHO. Job's done.
ECHO.
REM PAUSE

Copy and save this script as organizephotos.bat on your home directory. Then you can either run it manually, or better set a time schedule to run it periodically.

I hope this works for you too! Best.

Search Dos Batch to Organize Photos By Date on Google