Mercurial > ec-dotfiles
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 172:30de37b6fe47 | 173:2b7c8c1ecdfe |
|---|---|
| 141 echo "Checking for errors..." | 141 echo "Checking for errors..." |
| 142 # THE FILES | 142 # THE FILES |
| 143 | 143 |
| 144 # current dir: ${BASE_DIR}/${SITE_DIR}/${TARGET_DIR} | 144 # current dir: ${BASE_DIR}/${SITE_DIR}/${TARGET_DIR} |
| 145 cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}" | 145 cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}" |
| 146 TRASH_DIR="${SITE_DIR}-${TARGET_DIR}-`date -u +%Y%m%d-%H.%M`" | |
| 147 mkdir -p "${BASE_DIR}/trash/${TRASH_DIR}" | |
| 146 for TRASH in `ls | sed -e 's/\([0-9a-f]\{32\}.*\)//g' | grep -v ^$` | 148 for TRASH in `ls | sed -e 's/\([0-9a-f]\{32\}.*\)//g' | grep -v ^$` |
| 147 do | 149 do |
| 148 mv -f "${TRASH}" "${BASE_DIR}/trash" || Err_Fatal "Error deleting files" | 150 mv -f "${TRASH}" "${BASE_DIR}/trash/${TRASH_DIR}" || Err_Fatal "Error deleting files" |
| 149 echo "Moved ${TRASH} to ${BASE_DIR}/trash" | 151 echo "Moved ${TRASH} to ${BASE_DIR}/trash/${TRASH_DIR}" |
| 150 done | 152 done |
| 153 [ "`ls "${BASE_DIR}/trash/${TRASH_DIR}"`" ] || rmdir "${BASE_DIR}/trash/${TRASH_DIR}" | |
| 151 printf "" > "${BASE_DIR}/temp/${SITE_DIR}-${TARGET_DIR}-error" | 154 printf "" > "${BASE_DIR}/temp/${SITE_DIR}-${TARGET_DIR}-error" |
| 152 for FILE in * | 155 for FILE in * |
| 153 do | 156 do |
| 154 if [ "`${MD5} "${FILE}" | cut -d ' ' -f1 -`" != "`echo "${FILE}" | cut -d '.' -f1`" ] | 157 if [ "`${MD5} "${FILE}" | cut -d ' ' -f1 -`" != "`echo "${FILE}" | cut -d '.' -f1`" ] |
| 155 then | 158 then |
