Ubuntu – How to make an entire directory executable

chmodcommand lineexecutablescripts

I have an entire folder dedicated to python scripts.

I'm tired of doing chmod on every new python script that I write.

Is there a way to make every file inside my folder executable if it is a python script?

It would be nice to have a script that checks whenever a new .py script is created and if there is a new .py script make it executable right there on the spot.

  • I use Vim.

Best Answer

Another good option is Incron. It works on inotify with specifiable conditions for a given location.

So I can say watch this folder, when you see a file created, run a command.

Just as a sample incrontab...

/path/to/scripts IN_CREATE chmod +x $@$#  # <--- this arcane bit is path ($@) + file ($#)

One could similarly use the path/file as arguments to a bash script to allow it to filter by .py extensions if needed.