Use rar.exe to create an archive file, how to name it accord to the original file?

0

I have a file named windows tutorial.pdf and its size is 140M. I use the rar.exe command from WinRAR to archive it.

rar.exe a -v50m archive.rar "windows tutorial.pdf"

The upper code will create a list of files.

archive.part01.rar
archive.part02.rar
archive.part03.rar

My question is, it there an easy way to specify the archive file name using the original file name (instead of specify it directly in the command like rar.exe a -v50m "windows tutorial.rar" "windows tutorial.pdf")? In this case, what I want is

windows tutorial.part01.rar
windows tutorial.part02.rar
windows tutorial.part03.rar

Yousui

Posted 2011-07-01T09:31:36.147

Reputation: 1 287

Answers

2

You could write a little batch file to do this for you.

Just create this file with a .cmd or .bat extension:

rar.exe a -v50m "%%~n1.rar" %%1

Then, run it with the file as a parameter:

myrar.cmd "windows tutorial.pdf"

%%1 is the first parameter passed to the batch file. The ~n prefix makes the variable return only the filename, without the extension. For more information on this behavior, see this answer on Stack Overflow.

Patches

Posted 2011-07-01T09:31:36.147

Reputation: 14 078