Mercurial > ec-dotfiles
diff moefetch.sh @ 173:2b7c8c1ecdfe
better trash handler
author | edhoprima@gmail.com <edhoprima@gmail.com> |
---|---|
date | Fri, 05 Jun 2009 20:12:15 +0000 |
parents | 30de37b6fe47 |
children | 0948e76a57a1 |
line wrap: on
line diff
--- a/moefetch.sh Fri Jun 05 19:59:51 2009 +0000 +++ b/moefetch.sh Fri Jun 05 20:12:15 2009 +0000 @@ -143,11 +143,14 @@ # current dir: ${BASE_DIR}/${SITE_DIR}/${TARGET_DIR} cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}" + TRASH_DIR="${SITE_DIR}-${TARGET_DIR}-`date -u +%Y%m%d-%H.%M`" + mkdir -p "${BASE_DIR}/trash/${TRASH_DIR}" for TRASH in `ls | sed -e 's/\([0-9a-f]\{32\}.*\)//g' | grep -v ^$` do - mv -f "${TRASH}" "${BASE_DIR}/trash" || Err_Fatal "Error deleting files" - echo "Moved ${TRASH} to ${BASE_DIR}/trash" + mv -f "${TRASH}" "${BASE_DIR}/trash/${TRASH_DIR}" || Err_Fatal "Error deleting files" + echo "Moved ${TRASH} to ${BASE_DIR}/trash/${TRASH_DIR}" done + [ "`ls "${BASE_DIR}/trash/${TRASH_DIR}"`" ] || rmdir "${BASE_DIR}/trash/${TRASH_DIR}" printf "" > "${BASE_DIR}/temp/${SITE_DIR}-${TARGET_DIR}-error" for FILE in * do