Jump to content

Workflow Question


Recommended Posts

Hiya,

 

So I'm trying to write a workflow to speed up my morning...

Every day I work with 3 applications. These have there own folders for where I store the documents. After each day I save the documents with there file name and rev number e.g "Plan Drawing RevG1"

Each morning I then go into each folder and open up the latest saved file.

 

I wondered if there was a workflow that I could create that would look into each of the 3 folders and open the latest saved/modified document of a specific file type and open it with specified application, without no more than a single Hotkey Press.

 

Thankyou in advance for your help.

I love the app, its so helpful

 

Sincerely

 

Sammy The Hand

Link to comment

Hiya,

 

So I'm trying to write a workflow to speed up my morning...

Every day I work with 3 applications. These have there own folders for where I store the documents. After each day I save the documents with there file name and rev number e.g "Plan Drawing RevG1"

Each morning I then go into each folder and open up the latest saved file.

 

I wondered if there was a workflow that I could create that would look into each of the 3 folders and open the latest saved/modified document of a specific file type and open it with specified application, without no more than a single Hotkey Press.

 

Thankyou in advance for your help.

I love the app, its so helpful

 

Sincerely

 

Sammy The Hand

 

Moving this to the Workflow Help & Questions section so that you can get help from fellow workflow creators.

Link to comment
Theoretically, do this:
 
(1) Create a new workflow with a script action.
(2) Make the script action "bash"
(3) Paste the following into the script box
 
folders=()
folders+=("/full/path/to/folder1")
folders+=("/full/path/to/folder2")
folders+=("/full/path/to/folder3")


for folder in ${folders[@]}; do
    file=$(find "${folder}" -maxdepth 1 -type f -print0 | xargs -0 stat -f "%m %N" | sort -rn | head -2 | grep -v .DS_Store | cut -f2- -d" ")
    open "${folder}/${file}"
done

(4) Alter lines 2–4 to be the paths to your folders

(5) Create a hotkey trigger that links to the script action

(6) Set the hotkey

(7) Press the hotkey and see if it works.

 

 

So, the script will look at each folder and find the most recently modified file (excluding .DS_Store) and open it. I haven't tested the script, but it should work. If it doesn't, double-check the outputs for the two variables ($folder and $file) to make sure that they form a valid path.

 

---

 

Edited to quote the "${folder}" so that spaces in the path don't break it.

Edited by Shawn Rice
Link to comment

should be easy to debug... :)

 

Yes. Listen to dfay.

 

---

 

Actually, to go through the debugging process:

 

I would start with:

echo $(find "/path/to/folder1" -maxdepth 1 -type f -print0 | xargs -0 stat -f "%m %N" | sort -rn | head -2 | grep -v .DS_Store | cut -f2- -d" ")

Then, start cutting parts of the line out, starting at the end.

echo $(find "/path/to/folder1" -maxdepth 1 -type f -print0 | xargs -0 stat -f "%m %N" | sort -rn | head -2)
echo $(find "/path/to/folder1" -maxdepth 1 -type f -print0 | xargs -0 stat -f "%m %N" | sort -rn)
echo $(find "/path/to/folder1" -maxdepth 1 -type f -print0 | xargs -0 stat -f "%m %N")
echo $(find "/path/to/folder1" -maxdepth 1 -type f -print0)
cd "/path/to/folder1"; ls -lta

That sort of thing. When you find what isn't working, then make it work, and then start adding things back in. Use the last command to make sure that you're grabbing the correct file. If you want to open the file in a different program, then you'll have to add in some arguments to the "open" command (I forget them off the top of my head).

Edited by Shawn Rice
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...