From 10cf26725b09a80f30665d203446879ea061ea3e Mon Sep 17 00:00:00 2001 From: committer Date: Wed, 12 Jun 2024 18:04:59 -0500 Subject: [PATCH] u --- dots/bin/tp.sh | 77 ++++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 46 deletions(-) diff --git a/dots/bin/tp.sh b/dots/bin/tp.sh index 8530437..6de686b 100755 --- a/dots/bin/tp.sh +++ b/dots/bin/tp.sh @@ -24,64 +24,49 @@ log_file="/home/poq/syncDir/0_downloads/tp.log" #echo "sync_dir: ${sync_dir}" #echo "cwd: ${cwd}" #echo -echo "---" >> ${log_file} +#echo "---" >> ${log_file} #echo "$@" >> ${log_file} # loop through all files to delete for input_file in "$@"; do # lf file manager sends multiple files as one input parameter, split by with newlines + # https://superuser.com/questions/284187/bash-iterating-over-lines-in-a-variable + declare -a theArray + while read -r line + do + theArray+=("$line") + done <<< "$input_file" -declare -a theArray + for line in "${theArray[@]}" + do + #echo "$line" >> ${log_file} -while read -r line -do - theArray+=("$line") -done <<< "$input_file" + # if input file has no path specified + if [[ ${input_file} != *"/"* ]]; then + input_file="${cwd}/${input_file}" + fi -for line in "${theArray[@]}" -do - echo "$line" >> ${log_file} - #Do something complex here that would break your read loop -done + # substitute parts of the old path, from using the symlink folder, to the non-symlink folder + # example: + # "/home/poq/syncDir/0_downloads/topBanner.jpg" > "/home/poq/nextcloud/syncDir/0_downloads/topBanner.jpg" + # + # 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. -# while IFS= read -r line; do -# echo "... $line ..." + # new_file=${original_string//old_substring/new_substring} + new_file=${input_file//$sync_dir_sym/$sync_dir} -# for line in "$input_file" -# do -# echo ${line} >> ${log_file} -# done + if [[ -f "${new_file}" ]] || [[ -d "${new_file}" ]] ; then + #trash-put "${new_file}" + #echo "${new_file}" + echo "${new_file}" >> ${log_file} + else + echo "error: unable to delete \"${new_file}\"" + fi -# while IFS= read -r line; do -# echo "... $line ..." -# done <<< "$list" - - -# for input_file in - -# # if input file has no path specified -# if [[ ${input_file} != *"/"* ]]; then -# input_file="${cwd}/${input_file}" -# fi -# -# # substitute parts of the old path, from using the symlink folder, to the non-symlink folder -# # example: -# # "/home/poq/syncDir/0_downloads/topBanner.jpg" > "/home/poq/nextcloud/syncDir/0_downloads/topBanner.jpg" -# # -# # 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 -# #trash-put "${new_file}" -# echo "${new_file}" -# else -# echo "error: unable to delete \"${new_file}\"" -# fi + done done