0

I have 2 files test.part1.rar and test.part2.rar When extracting them using command

7z x -o* test.part1.rar

The output directory is a folder with test.part1 name I want the output directory to be a folder with name test (archive name without '.part1')

    From 7z documantation
    
        -o{dir_path}
        {dir_path}
        This is the destination 
directory path. It's not required to end with a backslash. If you specify * in {dir_path}, 7-Zip substitutes that * character to archive name.

1 Answers1

0

Maybe using parameter expansion will do what you seek.

f=test.part1.rar; 7z x -o ${f%%.*} $f

You may want to use the 7z e command if you don't want to extract with the full paths within the archive.

The * can be used within the output directory to be replaced by the archive name. It doesn't sound like you need that.

theherk
  • 6,954
  • 3
  • 27
  • 52
  • The problem is that * is not replaced by archive name when extracting multipart rar files ,but it is replaced by archive name+part1 –  Nov 09 '21 at 18:23
  • I see what you mean. You could do something like `f=test.part1.rar; 7z x -o ${f%%.*} $f` – theherk Nov 09 '21 at 19:41