Created
January 31, 2019 12:14
-
-
Save jadwigo/5eecf70776ded2909c19a857135e9b1f to your computer and use it in GitHub Desktop.
move many files to subdirectories
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
| #!/bin/bash | |
| # This script takes a directory with many files and moves all nnormal files | |
| # to a subdirectory with the year-month | |
| for i in * | |
| do | |
| if [ -f "$i" ] | |
| then | |
| filemonth=`stat --format=%y "$i" | cut -c 1-7` | |
| mkdir -p $filemonth | |
| mv "$i" "$filemonth/$i" | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment