# for mucking about with files.
cfgFileName="fileOperationsDefaults.src"
# specifically, merge, purge, and backup non-deltas
#set -o allexport
# should (eventually) have flags for --destructive, case insensitive, and
# load a list of files with associated actions
#function loadFileOperationsConfig {
#}
# process the list of files
function processFiles {
# loadFileOperationsConfig
if [ -d "${srcDirName}/cfg" ]; then
cfgFilePath="${srcDirName}/cfg/${cfgFileName}"
if [ -f "${cfgFilePath}" ]; then
. "${cfgFilePath}" && lt "Config file '${cfgFilePath}' successfully loaded"
# echo "${fileActions['MUSIC.LIB']}"
#showFileActionsArray
else
lt "Could not find file at '${cfgFilePath}', please debug."
fi
else
lt "Could not find '${srcDirName}/cfg', cannot load configuration."
fi
# showFileActionsArray
lt "Processing files..."
for file in "${!fileActions[@]}"; do
case ${fileActions[${file}]} in
"rm")
if [ ! -z "${@}" ]; then
if [[ "${@}" == *"--destructive"* ]]; then
# if action is 'rm'
eval "${fileActions[${file}]} --interactive=always '${file}'"
# @TODO setup command detection for rm, (r)sync, and "else" clause catchall
else
lt "Command '${@}' not recognized."
fi
else
lt "In --destructive mode, the '${fileActions[${file}]}' action would remove the file '${file}', but this is just a dry run, so nothing will be changed."
fi
;;
*)
"Not processing '${fileActions[${file}]}' for file '${file}', this is a dry run."
;;
esac
# echo "-->${file}:${fileActions[${file}]}"
done
lt "...done processing files."
}
#processFiles
# export fileActions