Command Prompt code in Context Menu

Hi.

How I can to insert the Command Promt code to Context Menu for files with certain extention type?

set UIFILE=%1 set UIDIR=%~dp1 set FILENAME=%~n1 set PSDNAME=%UIDIR%%FILENAME%_uis.py CALL C:\Python27\Scripts\pyside-uic.exe %UIFILE% -o %PSDNAME%

How I can layout this code in this window?


With the default toolbar goto File Types from Settings menu and double click the file extension you want from System File Types category. From there goto the Context Menu tab click new button on lower left. Select 'Run an Opus function' from Type drop-down then select 'MS-DOS Batch Funtion' from Function drop-down. Since you're using set in your batch you'll also want to include @externalonly at the top of the function.

[Overlaps with the previous reply. Both were written at the same time.]

Change the function type to MS-DOS Batch.

Add a line right at the start of the command with @externalonly on it, so it knows to run the MS-DOS Set command instead of the Opus Set command.

You might also want to add a pause command at the end if you don't want the DOS window to close until you push space, or add @leavedoswindowopen on another line at the start if you want the DOS window to stay open and continue accepting further typed commands.

Thanks.

I edited the code according to your instructions:


But a blank cmd-window displayed only.
Code does not work, even though the bat-file format is working properly.


The % codes you're using probably aren't generating what you're expecting in the context they're being run.

Try using some echo commands to see what things are outputting, which will help you debug your commands.

If you want to pass the filename and current folder, using Opus codes like {filepath$} and {sourcepath$} (or {sourcepath$|noterm} if you need to suppress the trailing backslash, which is sometimes needed with DOS commands) will usually be better than DOS batch % codes, especially since the .bat file will be running out of a temp folder, not the folder you might expect.

Thanks!

ОК. The code works:

@externalonly CALL C:\Python27\Scripts\pyside-uic.exe {filepath$} -o {sourcepath$}{file$|noext}_uis.py