История изменений
Исправление superuser, (текущая версия) :
Использовал твой пример. Так ошибок не будет?
#!/bin/bash
USAGE() {
echo "Use: $(basename $0) path-to-directory";
return 0
}
DO() {
(find "${1}" -type f -printf '%TY\0%p\0'; printf '\0\0') |
while IFS= read -r -d '' year; IFS= read -r -d '' fname; do
[[ -z $year ]] && echo "DONE." && break
[[ $fname = . ]] && continue
printf '[%s] [%s]\n' "$year" "$fname"
td="${1}_${year}/"
mkdir -p "${td}"
#cp --backup=numbered --preserve "${fname}" "${td}"
mv --backup=numbered "${fname}" "${td}"
done;
}
if [ $# -ne 1 ]; then
USAGE
exit 2
fi
echo "Source dir.: '$1'"
read -n1 -p "Press 'y' for continue... : " key
echo ""
case $key in
[y,Y])
DO "${1}"
exit 0
;;
*)
echo "Abort."
exit 1
esac
Исходная версия superuser, :
А так ошибок не будет?
#!/bin/bash
USAGE() {
echo "Use: $(basename $0) path-to-directory";
return 0
}
DO() {
(find "${1}" -type f -printf '%TY\0%p\0'; printf '\0\0') |
while IFS= read -r -d '' year; IFS= read -r -d '' fname; do
[[ -z $year ]] && echo "DONE." && break
[[ $fname = . ]] && continue
printf '[%s] [%s]\n' "$year" "$fname"
td="${1}_${year}/"
mkdir -p "${td}"
#cp --backup=numbered --preserve "${fname}" "${td}"
mv --backup=numbered "${fname}" "${td}"
done;
}
if [ $# -ne 1 ]; then
USAGE
exit 2
fi
echo "Source dir.: '$1'"
read -n1 -p "Press 'y' for continue... : " key
echo ""
case $key in
[y,Y])
DO "${1}"
exit 0
;;
*)
echo "Abort."
exit 1
esac