Jump to content

Creating a new file in a directory


Recommended Posts

I want to create a new taskpaper (just plain text) file in a directory i’m passing into alfred, and i’ve sorted it out but i’m wondering if there is a better way.

 

I used @Vero args and dates workflow as a bit of a template.

 

image.thumb.png.6b1172890141f952ad1e714599f6f893.png

 

and including the last var/arg before the write command so you can see the string. It does what i need it to do but curious if there is smarter more efficient way.

 

Thanks!

 

image.thumb.png.f8de564e7ae43f683b459eb39f7f2a8c.png

 

Link to comment

It seems to me that you're getting simply the folder name from the Universal Action. In that case, am I correct in assuming the folder in which you wish to create the new file varies (i.e., it's not the same folder all the time)? (I'm sure that must be the case from what your workflow appears to do but I just wanted to check!).

 

Stephen

Link to comment

The way you’re doing it seems pretty straightforward and clear. Is there a way with fewer objects? Perhaps, if you want to write some code in a Run Script, but I wouldn’t necessarily call that solution smarter or more efficient. It’s doubtful the extra spent time would bring any tangible benefit¹.

 

If you can describe a specific issue you’d like to see solved with your approach, we can try to guide you better. E.g. if you’re worried about reusability, I could point you at prefabs.

 


¹ Always excluded: if the reason is just “I want to learn”.

Link to comment
2 hours ago, Stephen_C said:

It seems to me that you're getting simply the folder name from the Universal Action. In that case, am I correct in assuming the folder in which you wish to create the new file varies (i.e., it's not the same folder all the time)? (I'm sure that must be the case from what your workflow appears to do but I just wanted to check!).

 

Stephen

Yes that is correct.

Link to comment
1 hour ago, vitor said:

The way you’re doing it seems pretty straightforward and clear. Is there a way with fewer objects? Perhaps, if you want to write some code in a Run Script, but I wouldn’t necessarily call that solution smarter or more efficient. It’s doubtful the extra spent time would bring any tangible benefit¹.

 

If you can describe a specific issue you’d like to see solved with your approach, we can try to guide you better. E.g. if you’re worried about reusability, I could point you at prefabs.

 

 


¹ Always excluded: if the reason is just “I want to learn”.

@vitor your footnote is correct, I'm definitely just wanting to learn alternate ways and have been trying to use alfred as a means to teach myself some scripting.

Link to comment

actually i spoke too soon @vitor. It appears my path is being truncated after i input the filename. I'm sending a folder to Alfred and running the above workflow as a universal action. If i just run get path dirname universal action it returns this path:

 

 /Volumes/Remote Audio IV/PODCAST/TASKPAPER DOCS

 

but when i connect it to the rest of the workflow it is getting truncated somehow.

 

that path is stored in the first variable but after i input the filename using the keyword the path gets truncated to  "/Volumes/Remote Audio IV/PODCAST/" do you have any idea why that might be occurring?

 

attaching screen shots of how i'm storing variables.

 

first var:

image.thumb.png.db1e329096c48f948bb8c5aac8f4bd74.png

 

 

variable for the filename post keyword entry

image.thumb.png.87cc90e0af5fd01471f2f5f731a1b519.png

 

and then the string before the write text file

 

image.thumb.png.9c96becd2cd0e030cd85d7f8e11a8fb2.png

 

 

 

Link to comment
7 hours ago, sepulchra said:

 /Volumes/Remote Audio IV/PODCAST/TASKPAPER DOCS

Does it make any difference if:

  • there is not a space in the final item in the path; or
  • if an otherwise identical path is used on local disk (i.e., not on an external mounted volume)?

 

Edit: what is the output of the debugger when you run the workflow?

 

Stephen

Edited by Stephen_C
Link to comment
1 hour ago, vitor said:

It’s behaving as it’s supposed to. A path’s dirname is the full path to its parent. If you want the full path use it directly, don’t process it in the Automation Task.

@vitorwhat is the best way to get the full path in workflow? I'm often sending a folder to alfred with a hotkey and taking action. Is there a way to leverage Alfred to "copy full path" file action but inside a workflow in place of my automation task? or a better way? I guess I could alway put the rest of the path in the name, but that seems less efficient. Thanks!

 

 

SOLVED: The automation task was entirely unnecessary as the universal action/file action outputs the full path. I don't know why I never realized it! 

Edited by sepulchra
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...