.bat Files for Mac

Wondering if there’s .bat file alternatives for Mac. I can easily make .bat files in Windows, by opening Notepad and saving as .bat, but when I try and make a .sh file in Mac using TextEdit, it doesn’t even seem to recognize it properly. The .bat files you can double click to run in Windows, but for Mac, using .sh just opens up TextEdit. Even if I manually select Terminal, it doesn’t seem to work. If .sh files do work for Mac, in that same manner where you just double click them, then I’m not sure what I’m doing wrong.

I never used a mac but maybe there’s a way you can make it executable using permissions? Like “chmod +x”

1 Like

You are looking for AppleScript.

2 Likes

… or Python :slight_smile: … or any other scripting language (…Ruby is apparently still very much a thing for some reason).

What are you trying to do?

1 Like

You need to set the file as executable

Same with java files

Right click more info brings up a tab with settings select executable

I don’t see what you’re talking about. When I right click I select “Get Info”, but there’s nothing there for setting it as an executable.

Ruby did nothing wrong! Most of the hate comes from Ruby On RAILS.

chmod +x was a thing on OS X several generations ago, i dont know if it still is. full on real crunch bang unix scripting is possible. as well as crontab.

One of the well regarded tools for automation is keyboard maestro:

Without using third party tools, AppleScript is the most useful if you grant your script accessibility permissions, that way you can click at x, y on a given monitor, send key strokes to standard in, and access the clipboard.

I have usually invoked AppleScript commands from within a shell script.

The most recent time I used AppleScript was to scrape a website protected by the duo two factor authentication system. I used a shell script to send commands to safari, then did select all, copy, then the shell command to send the results to a text file named based on the query string. The scrape was performed by an authored user against a system that did not disallow that behavior (as they thought it was impossible).