sepulchra Posted December 1, 2018 Share Posted December 1, 2018 I've attached a screen shot an automator workflow that a bunch of folders and subfolders. it prompts the user to name the parent folder and choose a destination. I'm wondering if there is a way to accomplish this completely within an alfred workflow? Link to comment
deanishe Posted December 1, 2018 Share Posted December 1, 2018 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
sepulchra Posted December 1, 2018 Author Share Posted December 1, 2018 @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
deanishe Posted December 1, 2018 Share Posted December 1, 2018 19 minutes ago, sepulchra said: type file name of project folder name 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. Link to comment
sepulchra Posted December 1, 2018 Author Share Posted December 1, 2018 (edited) 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 December 1, 2018 by sepulchra Link to comment
deanishe Posted December 1, 2018 Share Posted December 1, 2018 Workflow with a File Action to create a tree of directories. Link to comment
sepulchra Posted December 1, 2018 Author Share Posted December 1, 2018 Thanks for that. It gives me something to review so i can understanding some basic shell scripting. I appreciate that. To date. I have just been grabbing bits here an there to make stuff work. Link to comment
huskyhusky Posted October 26, 2021 Share Posted October 26, 2021 (edited) On 12/1/2018 at 8:05 PM, deanishe said: Workflow with a File Action to create a tree of directories. 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 October 27, 2021 by huskyhusky Quote Link to comment
deanishe Posted October 27, 2021 Share Posted October 27, 2021 (edited) 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 October 27, 2021 by deanishe Fix script Link to comment
huskyhusky Posted October 27, 2021 Share Posted October 27, 2021 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
deanishe Posted October 27, 2021 Share Posted October 27, 2021 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
huskyhusky Posted October 27, 2021 Share Posted October 27, 2021 2 hours ago, 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" Funktioniert perfekt. Dank dir! Link to comment
clement Posted January 17, 2023 Share Posted January 17, 2023 On 12/1/2018 at 1:05 PM, deanishe said: Workflow with a File Action to create a tree of directories. 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. Link to comment
huskyhusky Posted January 17, 2023 Share Posted January 17, 2023 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
huskyhusky Posted August 23, 2023 Share Posted August 23, 2023 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now