Jump to content

Folder Directory Workflow


Recommended Posts

Yes, it is. If you want to use Alfred to pick the destination directory, you should implement it as a File Action, i.e. select a directory in Finder or Alfred (or most other apps), then you can run Alfred's File Actions on it and choose "Create New Folders…" (or whatever) to run your workflow.

 

FWIW, mkdir has a -p option to create intermediate directories, and you can use {...} for multiple directories, so:

mkdir -p "$1/$2/{INTV,TRACKING,MUX SFX,RAW TAPE,SELECTS}"
mkdir -p "$1/$2/SESSIONS/{CHAP 1,CHAP 2, CHAP 3,CHAP 4,CHAP 5,STRINGOUTS}"

should create all of your directories with less typing.

Link to comment

@deanishe thank you! I managed to get that to work. It creates the folders! I'm new to this, is there a way to choose the destination directory and then pass a {query} that names the parent folder these folders would reside with. i.e.

 

 - navigate to directory 

- choose file action

- type file name of project folder name

- run mkdir scripts 

 

I'm just stabbing in the dark.

 

Link to comment
5 hours ago, deanishe said:

 

Store the incoming query (the directory path) in a variable, then use a Keyword to ask for the name of the parent directory. Now you can access both variables from your script.

I'm afraid i am now in over my head. I'm not sure how to store the path i navigated to within alfred in a variable and then then use a Keyword to ask for the name of the parent directory. And modify the script to accept those variables. I apologize but i am learning as i go.

Edited by sepulchra
Link to comment
  • 2 years later...
On 12/1/2018 at 8:05 PM, deanishe said:

 

I already use your workflow very often. I would just like to make a change that I somehow can't manage myself. I would like the workflow not to ask for a new name, but to always follow the parent folder. 

So I want to create a folder that I name XY. Then I want to execute the folder action which creates subfolders (XY_1, XY_2, XY_3 etc.).

How can I work around the second variable? Unfortunately I don't know enough about this topic :( Thanks for your help. 

 

 

Edited by huskyhusky
Quote
Link to comment
22 hours ago, huskyhusky said:

Then I want to execute the folder action which creates subfolders (XY_1, XY_2, XY_3 etc.).

 

Connect your File Action to this Run Script (Language = /bin/zsh):

 

# for directory X/Y/Z, create X/Y/Z/Z_1 through X/Y/Z/Z_5
for n in $( seq 1 5 ); do
	mkdir -vp "${1}/${1:t}_${n}" >&2
done

# pass root directory path to next action
echo -n "$1"

 

Edited by deanishe
Fix script
Link to comment
7 minutes ago, deanishe said:

 

Connect your File Action to this Run Script (Language = /bin/zsh):

 

# for directory X/Y/Z, create X/Y/Z/Z_1 through X/Y/Z/Z_5
for n in $( seq 1 5 ); do
	mkdir -vp "${1}/${1:t}_${n}" >&2
done

# pass root directory path to next action
echo -n "$root"

 

 

Thank you very much! You are a legend.

What if I would like to have words as suffix instead of numbers? Like xy_stock, xy_graphics and so on? 

 

 

Link to comment
23 minutes ago, huskyhusky said:

What if I would like to have words as suffix instead of numbers? Like xy_stock, xy_graphics and so on?

 

suffixes=(stock graphics "and so on")

for s in $suffixes; do
	mkdir -vp "${1}/${1:t}_${s}" >&2
done

# pass root directory path to next action
echo -n "$1"

 

Link to comment
  • 1 year later...
7 hours ago, clement said:

 

How do we use it? I tried going to finder and doing right-click or launching Alfred and typing "Create Folder..." while having finder but nothing showed up.

 

Thanks for creating this though.

 

I use a simple workflow. I assigned a shortcut (F12) with the action „Pass through to workflow" and as argument „selection in MacOs” and connect this to this script. This way you have to select a folder in the finder, press F12 and the folder are created by this simple press.

 

Hope that helps

Link to comment
  • 7 months later...
On 10/27/2021 at 11:21 AM, deanishe said:

 

suffixes=(stock graphics "and so on")

for s in $suffixes; do
	mkdir -vp "${1}/${1:t}_${s}" >&2
done

# pass root directory path to next action
echo -n "$1"

 

 

 

 

This workflow is used at least three times a day, so thanks again! 

 

I would like to ask for an alternative. And I would like that I again that the parent folder name is grabbed, but there only the first 6 digits or up to the first hyphen.

 

230823-Testordner/

230823-Testordner/230823-stock

230823-Testordner/230823-graphics

 

So that the date is taken, but nothing behind it and then the suffix is appended again. Is that possible?

 

 

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...