holy shit it works, thanks man, you're a hero.
Thank you for your effort put into this.
I'm probably going to continue to edit it (in case you copied it to a text file or something) for instance I changed the "$(file -b /path/to/something)" part to see if the output contains "Mach-O 64-bit executable x86_64" rather than exactly "Mach-O 64-bit executable x86_64" in case of an executable being universal (this means so the chmod part runs in order to set the execute permission on the executable)