Skip to content

Commit

Permalink
Merge pull request #16 from pugetsoundandvision/delete-hidden-files
Browse files Browse the repository at this point in the history
Delete hidden files
  • Loading branch information
alavigne12 authored Jan 10, 2019
2 parents 84eeb16 + 6015534 commit 6c682ee
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions videoaip
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ _set_up_crop(){

_error_exit(){
echo -e "\033[1;32m"$1"\033[0m" 1>&2
continue
}

OPTIND=1
while getopts "hecl:" opt ; do
while getopts "hecxl:" opt ; do
case "${opt}" in
h) usage ;;
e) runtype="edit";;
c) runtype="crop";;
x) hiddenFiles="preserve";;
l) logfiles+=("${OPTARG}");;
*)
esac
Expand Down Expand Up @@ -127,8 +127,9 @@ while [ "${*}" != "" ] ; do
file_input="${1}"
shift

if [ ! -f "$file_input" ]; then
_error_exit "Input could not be found. Please enter valid input."
if [ ! -f "${file_input}" ]; then
_error_exit "Input: ${file_input} could not be found. Please enter valid input."
continue
fi

#set variables
Expand All @@ -139,6 +140,7 @@ while [ "${*}" != "" ] ; do

if [ -d "${targetdirectory}/${mediaid}" ] ; then
_error_exit "Directory already exists. Exiting..."
continue
fi

#crop mode
Expand All @@ -164,7 +166,7 @@ while [ "${*}" != "" ] ; do
fi

#create directory structure
mkdir "${targetdirectory}/${mediaid}" || _error_exit "Directory already exists. Exiting..."
mkdir "${targetdirectory}/${mediaid}" || ( _error_exit "Directory already exists. Exiting..." && continue )
mkdir "${targetdirectory}/${mediaid}/metadata"
mkdir "${targetdirectory}/${mediaid}/logs"
mkdir "${targetdirectory}/${mediaid}/logs/fileMeta"
Expand Down Expand Up @@ -232,14 +234,24 @@ while [ "${*}" != "" ] ; do

#Run Bagit
echo -e "\033[1;32mCreating Bag\033[0m"
bagit baginplace --excludehiddenfiles "$package"
if [ "${hiddenFiles}" = 'preserve' ] ; then
bagit baginplace "$package"
else
find "$package" -type f -iname ".*" -exec rm -f {} \;
bagit baginplace --excludehiddenfiles "$package"
fi
bagit baginplace "$package"

#sync AIP to destination
if [[ "${sync_choice}" = [yY] ]] ; then
for i in "${destination[@]}" ; do
if [ -d "${i}" ] ; then
echo -e "\033[1;32mSyncing Files to "${i}" \033[0m"
rsync -Pa "$package" "${i}"
if [ "${hiddenFiles}" = 'preserve' ] ; then
rsync -Pa "$package" "${i}"
else
rsync -Pa --exclude ".*" "$package" "${i}"
fi
if ! [ "${?}" = "0" ] ; then
SYNC_PROBLEM="1"
fi
Expand Down

0 comments on commit 6c682ee

Please sign in to comment.