Page 1 of 1

I think I threw this code in Hazel, but it still doesn't wor

PostPosted: Tue Sep 13, 2022 8:48 am
by ikatod
Hi
guys, can someone help? I think I threw this code in Hazel, but it still doesn't work =(
https://monosnap.com/file/cUFVdE5EYwWqp ... SgYnzqQzTP

Code: Select all
for file1 in /Users/ikatod/Resilio Sync/Realese/Basa/*.*
   do
      filename1=$(basename "${file1%.*}")
      for file2 in /Users/ikatod/Resilio Sync/Realese/Scan/*.*
   do
      filename2=$(basename "${file2%.*}")
      if [ "$filename1" = "$filename2" ];
      then
         cp "$file1" /Users/ikatod/Resilio Sync/Realese/Old/
         mv "$file2" /Users/ikatod/Resilio Sync/Realese/Old/
      else
         continue
      fi
   done
   done

Re: I think I threw this code in Hazel, but it still doesn't

PostPosted: Tue Sep 13, 2022 9:29 am
by Mr_Noodle
It looks like this script is better run on its own. It doesn't make sense to have Hazel trigger this as it is. Can you describe in detail what you are trying to do exactly?

Re: I think I threw this code in Hazel, but it still doesn't

PostPosted: Tue Sep 13, 2022 9:41 am
by ikatod
Mr_Noodle wrote:It looks like this script is better run on its own. It doesn't make sense to have Hazel trigger this as it is. Can you describe in detail what you are trying to do exactly?

I need Hazel to check and run this script. When the same files appear in the Scan and Basa folders.
1 w030 2104.jpeg
1 w030 2104.pdf
As soon as the same files appear there, they should be moved to the Old folder

Re: I think I threw this code in Hazel, but it still doesn't

PostPosted: Wed Sep 14, 2022 9:19 am
by Mr_Noodle
You shouldn't have the script loop through the files. Hazel already does that. Instead, you have a script as the condition which checks whether both files are there for each file in the monitored folder. Then in the action, a separate script that will move them.