Files
piscal/piscal-manager/subdir_year.sh
2022-09-19 11:48:27 -04:00

15 lines
396 B
Bash
Executable File

#!/bin/bash
for file in *; do
## Skip unless this is a file
if [ -f "$file" ]; then
## get the first four characters from filename, aka the year
target="${file:0:4}"
## Create the target directory if it doesn't exist
[ -d "$target" ] || mkdir "$target" 2>/dev/null
## Move the current file
mv "$file" "$target" 2>/dev/null
fi
done