Button to create a folder, enter it, and run command in Windows Terminal from it

I've been trying to search in the forum and around, tried a few ways based on pieces of buttons I already have, but I can't find the proper way.

For the first part, I'm ok, I can create a folder with a prompt for name and enter it with this command:

@set folder_name = {dlgstringS|Enter the name for the new folder:}
CreateFolder "{$folder_name}"
Go "{$folder_name}"

After this, I keep failing. I'd like to open CMD from Windows Terminal and run a command, in my case, the command is:

npx create-bolt-uxp

Every attempt would fail, either saying it cannot find the path, or the command, etc.

So many and often very similar that it would probably be more confusing to post them, but here's one:

@set folder_name = {dlgstringS|Enter the name for the new folder:}
CreateFolder "{$folder_name}"
Go "{$folder_name}"
C:\Windows\System32\cmd.exe /c start "" wt.exe -d "{sourcepath$}" ; npx create-bolt-uxp

Something tells me that it is easier than I think, I just hope I didn't miss something that is already around here.

Thanks.

Try

@nofilenamequoting
@set folder_name = {dlgstringS|Enter the name for the new folder:}
CreateFolder "{$folder_name}"

wt.exe -d "{sourcepath$}{$folder_name}" cmd /k "npx create-bolt-uxp"

Thanks, this is definitely doing what I was looking for, but it also made me realise that the first part, about creating the folder and enter it, is pointless as the command it will also create a folder.

What would be the line to just run the command in the current folder?

I thought, I just need to remove the first few lines and leave the sourcepath in the command, but it fails. I still have problem on how to control the path on dopus commands

If you just want to run a couple of commands from a command line in the source directory, all you need to do is set the button type to DOS, e.g.

Opus will handle the paths behind the scenes. If you want to know how, look for dop*.bat files in /temp.

Thanks, I was hoping for a internal command so that I could implement the {dlgchoose}, which I know already how to use. In that way I don't need to create a single button for each command, but if not possible, I guess this is the way, and I will make a button for each command.

I am not quite sure what your overall goal is. Maybe we'll find something if you share more details.

I was planning to create a dialogue with different options, one for Bolt UXP, let's say, one for Electron JS, and React JS. I managed to create that based on your answer with this:

@nofilenamequoting
@set folder_name = {dlgstringS|Enter the name for the new folder:}
CreateFolder "{$folder_name}"

wt.exe -d "{sourcepath$}{$folder_name}" cmd /k {dlgchoose|Commands List:|Bolt UXP="npx create-bolt-uxp my-app"+Electron JS="npx create-electron-app my-app"+React JS="npx create-vite@latest my-app --template react"}

This works, but then, I realised the first 3 lines are creating a folder, and then, the last line it's creating another folder inside there, so I find myself an extra level deep inside for no reason.

I'm trying to get the command from the last line to work in the current folder, but any attempt fails always something regarding not finding the path.

This might lack a few quotes.

Try instead:

@nofilenamequoting
@set folder_name = {dlgstringS|Enter the name for the new folder:}
CreateFolder "{$folder_name}"

@set command = {dlgchoose|Commands List:|Bolt UXP="npx create-bolt-uxp my-app"+Electron JS="npx create-electron-app my-app"+React JS="npx create-vite@latest my-app --template react"}

wt.exe -d "{sourcepath$}{$folder_name}" cmd /k "{$command}"

But this is the only part I need to work, I need to remove the lines that prompt to create and enter the folder

Ok it took me a bit, but I managed to make it in javascript, thanks for the help.