ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

Command line - Some questions

(1/2) > >>

Yaron:
I've created a batch file for zipping selected items in a folder.
(The file is placed in 'Send to').


If I use the following code:
for %%* in (.) do set CurrentFolder=%%~n* "C:\Program Files\WinRar\WinRar" a -afzip "%CurrentFolder%.xpi"

    The file name is that of the current folder (correct).
    All files are archived whether I select one file or multiple files (wrong).
    Selected folders are not archived (wrong).

If I use the following code:
set file=%~f1 "C:\Program Files\WinRar\WinRar" a -afzip "%file:~0,-4%.xpi" "%1"

    The file name is that of the file on which I right click (correct).
    Only that file is archived even if multiple files are selected (wrong).



How can I know if a single item is selected or more?
What's the condition syntax?
How can I include folders in the archive?


Thank you.

x16wda:
I don't think the "for" command works the way you want. But most archivers these days already have a context menu extension that should let you add files or folders to a compressed file - I expect Winrar should too. If it doesn't, check here for instructions to turn it on.

Yaron:
Thank you.

I'm trying to add "Compress to FileName.xpi".

x16wda:
I installed the Winrar trial, and I don't see that it's possible with the product. You can select files and folders and choose "Add to archive..." from the Winrar context menu, and the only choices it offers are RAR, RAR5 and ZIP. I don't see that it supports .xpi out of the box at all.

In my ignorance I looked up what xpi files are, and they appear to be plain zip files, preferably without compression, that include a install.rdf file, that are used to package Firefox extensions.  Do you create extensions a lot?  Or is there some advantage for naming archives with .xpi?

It looks like send-to sends a blank-separated list of files to a script. Create a batch file in C:\Users\whoever\AppData\Roaming\Microsoft\Windows\SendTo named tester.bat and add these two lines:

    echo %*%
    pause

and then select several files and send-to the tester.bat entry. You'll see the list contains the full filenames separated with a blank, with surrounding quotes if needed. I'd have to play with it a bit but should be able to write a batch to add files to a zip and then rename it to .xpi. I don't know that I'd use for, and I'd probably opt for the info-zip zip.exe for simplicity although I'd look at winrar's command line options.

Yaron:
Thank you. Special thanks for installing WinRar. It's really kind of you.

I'm not a developer, but I often make some small changes in Firefox extensions.
There are thousands of FF developers, and I've been wondering why the major archivers don't include the option to compress directly to XPI.

Please see this post:
https://www.donationcoder.com/forum/index.php?topic=37601.0

I'd be grateful for any further ideas.

*

And thanks to MilesAhead for his help and for referring me to this forum.

Navigation

[0] Message Index

[#] Next page

Go to full version