Move Directories Based on Name
I recently needed to restructure a folder that contained thousands of subdirectories and millions of files so that I could archive them in a (slightly) more manageable way. All of the files were organized into subfolders named after the day they were created, e.g. 9_11_2001
. At the very least, I wanted to split these by year so that I could tar
them separately.
Here's what I came up with:
find ./ -maxdepth 1 -type d -name "*_2022" -exec mv {} ./2022 \;