You can't put a dynamic button into a user command. The Go command needs to go directly into a button to create the drop-down menus.
Okay I got it to show the template folders but I am still unsure why this would be a replacement for the scripting version? With many templates I do not want them to take up a ton of toolbar space by creating a button for each template. I would still want a dropdown and a way for a user to change the template folders path when they want with just a folder search directory instead of changing a single path in the code each time.
You can put them inside toolbar menus, or the folder or folder-background context menus. Pretty much wherever you want.
And/or have toolbars for them that you toggle on and off when needed. (That'd be useful if you often need to do several in a row.)
create one of these, then put a new button with the FOLDERCONTENT
command as an item in the menu.
Looks nice!
However without jscript how can I rename the file and also change the template folder path visually instead of programmatically like I am doing with Scripting? I know once a user copies they can just go to the newly created file and rename it but it is just extra clicks to do so. How can I have it rename the file to the user choice before copying it over or right after copying it over with the menu button method?
You can pass a dialog with the COPYARGS
argument, e.g.
Go PATH=/programfiles FOLDERCONTENT=copytosource COPYARGS AS="{dlgstring}"
Thanks for your help once again! After trying this method without Jscript There are still two very important features missing that I can only seem to get working with the Jscript method.
- Warning the user they are about to overwrite a file if they use the same name as an existing file when copying.
- Changing the folder templates path to the users choice with a GUI search instead of having to do it manually in the button code.
Seems like something like this would be the simplest and most readable method tbh Just add a new button to the menu on the toolbar for any new template.
@Set NewFolderFromTemplate = {dlgstring|Enter Project Name}
CreateFolder {$NewFolderFromTemplate}
CreateFolder {$NewFolderFromTemplate}\WhateverSubDir1
CreateFolder {$NewFolderFromTemplate}\WhateverSubDir2
CreateFolder {$NewFolderFromTemplate}\WhateverSubDir1\DeeperFolder
If any folder already exists it won't overwrite it and delete the contents.
If you want to create templates that includes template files too you could create a user command that assigns persistent global variables with paths to each of the template files you might use like this:
// glob: For global variable glob!: For global variable that persists
@Set glob!:ExcelFileTemplate="C:\Test\TemplateExcelFile.xlsx"
Then you could just use the global in a copy command in any templates below the folders. It would even warn you if the file already exists.
Copy File={$glob:ExcelFileTemplate} To="{sourcepath$}\{$NewFolderFromTemplate}\WhateverSubDir1"
You'd only have to run the command to set the globals any time you update any of the files. And the nice thing is if you use any files in multiple folder templates, if you want to change the file or update it, you don't need to update all the template commands, just the global variable to the path and run it again.
Woah ThioJoe! Small world. Thanks for the help! I think I might have confused everyone here too much I will upload two comparisons here to show the difference between the Jscript implementation and the non scripting version that Leo is recommending. He keeps recommending not using scripting but the Jscript one works pretty well. If I can get a folder search gui for changing path and an overwrite popup then I will use the simpler method but I can't. If I am understanding correctly with your method I would have to update it whenever I update any of the templates, add new ones, or move to another folder to search for templates. Essentially what I want is an easy toolbutton to share with the rest of the Directory Opus community that they can just add to their toolbar and it will work since they can define their own path themselves. It just works right out of the box.
JSCRIPT
Opus Only
It just overwrites the folder with no alert and it also does not allow path changing like my Jscript version does. Maybe the jscript version is fine? If there is a way to mimic the jscript one with simpler code I am down for it
Is there a reason why I can't get the overwrite code to work here:
Go "F:\Assets Editing\Templates\Project Folder Templates" FOLDERCONTENT=copytosource COPYARGS AS="{dlgstring|Enter Project Name}" COPYFILETIMES=no WHENEXISTS=ask
I thought WHENEXISTS would work here.
Just found a way using an alias to have a dynamic template button with the Go command that Leo recommends while also giving the user the ability to change the path and still keep everything dynamic with the Menu!