Getting the current directory

Is it possible to obtain the name of folder I'm currently working in?
Eg. I'm in c:\windows, select "system32" and I would like to create archive file named "windows". I only found information on how to get the path, like {filepath|..} but I can't find how to get the rightmost dir name from the path. (This is default behavior of WinRAR when more than one file is selected.)
By the way - is it possible to check how many files are selected when executing DOpus command? And make some if-statements so the command can take different routes depending on how many files are selected.

{sourcepath$|nopath|noterm} will get you the name of the current directory

You can't do conditional branching except by calling a batch file or script. (You can call scripts within buttons by abusing the Rename Scripting system, FWIW, or you can have them in a separate script file which you call like any other program, passing the selected files as arguments.)

Thank you for your reply.

I have an entry in context menu for all files and folders:

@firstfileonly cd "{sourcepath} " "/programfiles\winrar\winrar.exe" a "{dlgstring|New file name|{sourcepath|nopath|noterm} {date|yy-MM-dd} {time|}}.zip" {allfile$}
It works ok until the current directory I'm working in contains a special character like ampersand or non-ASCII character - like polish letters: ąęłńóśćźż
Is there any workaround, is that code wrong for that purpose or is it a bug?

Does it work if you run WinRAR.exe manually with the same inputs?

Is it an MS-DOS type button or normal?

Standard Function (Opus or external)
Sorry, I didn't precise the problem - the problem appears when the prompt dialog from Opus appears: the default text in prompt dialog contains only the name of the current folder (including non-ASCII characters), but there's no date appended to it.

Nor time (why there's no option to update my last post? :confused: )

Are you sure it's the non-ASCII characters and not simply spaces in the directory name? Spaces will mess up what you're using as they'll trigger extra quotes to be inserted in the middle of the command.

Try this, which works for me at least:

@nofilenamequoting "/programfiles\winrar\winrar.exe" a "{dlgstring|New file name|{sourcepath|nopath|noterm} {date|yy-MM-dd} {time|}}.zip" @{allfile$|filem}

Same reason nobody reads the FAQs. :smiley:


You're right, it's the space, not non-ASCII characters that caused problems, unfortunately folders with non-ASCII characters I tested had also spaces in its names.