Return to closed documents?

Oftentimes when I’m plugged in at work on my MBP, I have a number of PDFs open at all times to quickly search, and a few excel spreadsheets that I keep open to pull data from. These are changing all the time, but when I unplug, it makes a lot of sense to quit out of these apps and others. Sometimes “reopen previous windows” doesn’t cover everything I need.

Is there a way to automatically quit specific apps and store down what documents were open in them, to then have open all those documents again with a trigger (not necessarily when reopening the app, in case I were to open a different spreadsheet or PDF before I’m getting back to work). I think KM would probably do the job, but I’m not sure. I have KM, Alfred, and Workspaces, for what it’s worth.

If it’s always the same batch of files you want open, you could do it with applescript, but since you have Keyboard Maestro I would just use it’s “Open a file, folder, or application” action for each file you want opened. You can also specify the application to use for each file if you want/need.

Unfortunately, it’s not the same batch of files each time. It’s whatever files I’m closing all at once when quitting out of that app.

I don’t know that KM is the right tool for this. AppleScript maybe? (assuming that the apps you’re talking about have good AppleScript support)