Jump to content

Create folder inside a folder (the same folder every time)


Recommended Posts

I regularly use the terminal to go into a folder (always the same folder called Codes) and make a folder, then use Alfred to open that new folder in vscode. 

 

I'd love to be able to just use alfred to create the folder itself rather than go into alfred to type cd Codes then type mkdir newFolderName in the terminal, and then go back to alfred to open it in vscode. I know this should be relatively easy considering the complex scripts I've seen people do, but I can't seem to figure it out.

 

Ideally i'd like to write just create hello, and that would create a folder in Codes called hello, and then open it in vs code with alfred, or even do it all in one smooth motion by writing something like co (create open), maybe (but that's really not needed, i might be able to tie those together myself if i have the create folder script). 

 

Anyone able to help me make this? ☺️ I've been bugging me head trying to figure it out but I know nothing about these things. My mac is set to zsh I think, if that matters.

(I saw some people had done similar things before, but the links were all mostly broken or not compatible anymore).

Edited by NorahMaria
Link to comment

Hi @NorahMaria, welcome to the forum.

 

You can use a Run Script action in Alfred basically like a command line. Set language to /bin/zsh and just put your command in there. Perhaps something like:

 

# input passed in from previous action, e.g. Keyword
name="$1"
# path of new directory to create
newdir="${HOME}/Codes/${name}"
# create directory
mkdir -p "${newdir}"
# open new directory in VS Code
/usr/bin/open -a "Visual Studio Code" "${newdir}"

 

Use a Keyword input to enter the name of the new directory and connect it to the above Run Script action.

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