+ support for multiple input files
This commit is contained in:
@@ -8,7 +8,6 @@ if [ $# -lt 1 ]; then
|
|||||||
echo "usage: '$this_file_name [path_to_file]'"
|
echo "usage: '$this_file_name [path_to_file]'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
#input_file=$1
|
|
||||||
input_files=( "$@" )
|
input_files=( "$@" )
|
||||||
|
|
||||||
sync_dir_sym=/home/${USER}/syncDir
|
sync_dir_sym=/home/${USER}/syncDir
|
||||||
@@ -17,30 +16,36 @@ sync_dir=${!syncdir_env_var} # '!' to use the name and not the value
|
|||||||
cwd=$(pwd)
|
cwd=$(pwd)
|
||||||
|
|
||||||
# nifty for debugging:
|
# nifty for debugging:
|
||||||
echo ${input_files}
|
#echo ${input_files[@]}
|
||||||
#echo ${sync_dir_sym}
|
#echo ${sync_dir_sym}
|
||||||
#echo ${sync_dir}
|
#echo ${sync_dir}
|
||||||
#echo ${cwd}
|
#echo ${cwd}
|
||||||
|
#echo
|
||||||
|
|
||||||
# if input file has not path specified
|
# loop through all files to delete
|
||||||
if [[ ${input_file} != *"/"* ]]; then
|
for input_file in ${input_files[@]}; do
|
||||||
input_file=${cwd}/${input_file}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# substitute parts of the old path, from using the symlink folder, to the non-symlink folder
|
# if input file has not path specified
|
||||||
# example:
|
if [[ ${input_file} != *"/"* ]]; then
|
||||||
# "/home/poq/syncDir/0_downloads/topBanner.jpg" > "/home/poq/nextcloud/syncDir/0_downloads/topBanner.jpg"
|
input_file=${cwd}/${input_file}
|
||||||
#
|
fi
|
||||||
# please note, if a file outside of the sync directory is tp'ed, then the replacement will not happen.
|
|
||||||
# this is great, as trash-put should work normally outside of the sync-dir. and for files residing outside,
|
|
||||||
# no replacemant should be done.
|
|
||||||
#
|
|
||||||
# new_file=${original_string//old_substring/new_substring}
|
|
||||||
new_file=${input_file//$sync_dir_sym/$sync_dir}
|
|
||||||
|
|
||||||
if [[ -f ${new_file} ]] || [[ -d ${new_file} ]] ; then
|
# substitute parts of the old path, from using the symlink folder, to the non-symlink folder
|
||||||
#trash-put ${new_file}
|
# example:
|
||||||
echo ${new_file}
|
# "/home/poq/syncDir/0_downloads/topBanner.jpg" > "/home/poq/nextcloud/syncDir/0_downloads/topBanner.jpg"
|
||||||
else
|
#
|
||||||
echo "error: unable to delete ${new_file}"
|
# please note, if a file outside of the sync directory is tp'ed, then the replacement will not happen.
|
||||||
fi
|
# this is great, as trash-put should work normally outside of the sync-dir. and for files residing outside,
|
||||||
|
# no replacemant should be done.
|
||||||
|
#
|
||||||
|
# new_file=${original_string//old_substring/new_substring}
|
||||||
|
new_file=${input_file//$sync_dir_sym/$sync_dir}
|
||||||
|
|
||||||
|
if [[ -f ${new_file} ]] || [[ -d ${new_file} ]] ; then
|
||||||
|
#trash-put ${new_file}
|
||||||
|
echo ${new_file}
|
||||||
|
else
|
||||||
|
echo "error: unable to delete ${new_file}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user