Skip to main content
1 of 7
grg
  • 205.6k
  • 45
  • 364
  • 495

You can use the following in Terminal. cd to the containing folder, then run the following:

find . -type f -exec bash -c \
  'F=$(echo "$1" | sed -E "s#^.{2}([0-9]{4})([0-9]{2})([0-9]{2})#\1/\2/\3#");\
  mkdir -p $(dirname "$F");\
  mv "$1" "$F"' - {} \;

find . -type f obtains every file in the current directory recursively.
-exec bash -c opens a shell to run the following commands.
F=$(…) opens a subshell and uses sed on the file path to obtain each of year, month and day.
mkdir -p $(dirname "$F") creates the directories to move the files into.
mv "$1" "$F" moves each file into its corresponding folder.

This takes the hierarchy on the left and converts it to the hierarchy on the right:

grg
  • 205.6k
  • 45
  • 364
  • 495