Problem with filepath argument

I am trying to make a simple command batch and have encountered a strange problem... I use {filepath$} for the commands and all works well, if I use it from the specific directory, e.g. C:\Main\Documents. However, when I view the files in the flat mode, the command is run as if {filepath$} was c:\Main\file.doc, not c:\Main\Documents\file.doc. This is somewhat unexpected and, in my opinion, erroneous. Any way to correct this?

{Filepath$} should result in the full path to each selected file, whether in flat view or not.

It sounds like you are using {sourcepath$}{file$} or similar instead of {filepath$}, unless I have misunderstood what your command is doing and which files/folders you are running it on.

Please tell us the full command you are running and some examples of what you have selected and the results you get for those selections.

Here is the full content of the command:

7z x "{filepath$}"
7z a "{filepath$|noext}.cbz" "{filepath$|noext}"
Delete "{filepath$|noext}" QUIET

When run in C:\Comics\One\ on One.cbr, it correctly extracts the content to a folder and packs it again to a .cbz file. When run in Flat mode from C:\Comics, it extracts the contents to a folder C:\Comics\ (instead of C:\Comics\One) and, naturally, fails to pack it again (as it cannot find the folder).

You haven't told 7z.exe where to extract the archive to on the first line, so it will extract it into the current path.

Try this:

@nofilenamequoting 7z x "{filepath$}" -o"{filepath$|noext}\" 7z a "{filepath$|noext}.cbz" "{filepath$|noext}\" Delete "{filepath$|noext}" QUIET