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

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

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
ikatod
 
Posts: 2
Joined: Tue Sep 13, 2022 7:27 am

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?
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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
ikatod
 
Posts: 2
Joined: Tue Sep 13, 2022 7:27 am

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.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support