Skip to content

Instantly share code, notes, and snippets.

@jadwigo
Created January 31, 2019 12:14
Show Gist options
  • Select an option

  • Save jadwigo/5eecf70776ded2909c19a857135e9b1f to your computer and use it in GitHub Desktop.

Select an option

Save jadwigo/5eecf70776ded2909c19a857135e9b1f to your computer and use it in GitHub Desktop.
move many files to subdirectories
#!/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