R tips and tricks – shell.exec

When you startup your machine, the first thing you do is to open the various programs you work with. Examples: your note-taking program, the pdf file that you need to read, the ppt file you were last working on, and of course your strongest link with the outside world nowadays; your email box. This post shows how to automate this process. Windows machines notoriously need restarting for every little (un)install. I trust you will find this startup automation advice handy.

The way to automate your workflow startup process is via the command shell.exec. Here is how you can use it to open whatever it is you need:

I imagine you don’t often move around files once they are saved where they should be saved, so those paths are fairly fixed. You can use the a tip given in a previous post to quickly reverse the backslashes before pasting the path into your code editor.

You can open multiple files for the same application (e.g. multiple pdfs). You can also rework the code for a bit more elegance:

Open your default browser with the pages you use most. Those few lines should help you feel comfortable clearing your web cache and data saved by aggressive browsers, your starting point is here:

For Python users, you can use the subprocess module to do the same as.

Less mousing around, more CTRL + Enter.
productivity image

Leave a Reply

Your email address will not be published. Required fields are marked *