Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • September 28, 2016, 01:47:23 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Command line - Some questions  (Read 2847 times)

Yaron

  • Participant
  • Joined in 2014
  • *
  • default avatar
  • Posts: 14
    • View Profile
    • Donate to Member
Command line - Some questions
« on: April 01, 2014, 06:18:21 PM »
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.
« Last Edit: April 01, 2014, 08:06:56 PM by Yaron »

x16wda

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 671
  • what am I doing in this handbasket?
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Command line - Some questions
« Reply #1 on: April 01, 2014, 07:59:10 PM »
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.
vi vi vi - editor of the beast

Yaron

  • Participant
  • Joined in 2014
  • *
  • default avatar
  • Posts: 14
    • View Profile
    • Donate to Member
Re: Command line - Some questions
« Reply #2 on: April 01, 2014, 08:08:59 PM »
Thank you.

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

x16wda

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 671
  • what am I doing in this handbasket?
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Command line - Some questions
« Reply #3 on: April 01, 2014, 09:06:02 PM »
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.
vi vi vi - editor of the beast

Yaron

  • Participant
  • Joined in 2014
  • *
  • default avatar
  • Posts: 14
    • View Profile
    • Donate to Member
Re: Command line - Some questions
« Reply #4 on: April 01, 2014, 09:44:34 PM »
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:
http://www.donationc...ex.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.

Yaron

  • Participant
  • Joined in 2014
  • *
  • default avatar
  • Posts: 14
    • View Profile
    • Donate to Member
Re: Command line - Some questions
« Reply #5 on: April 02, 2014, 10:00:14 PM »

mhitesky2002

  • Participant
  • Joined in 2015
  • *
  • default avatar
  • Posts: 1
    • View Profile
    • Donate to Member
Re: Command line - Some questions
« Reply #6 on: June 29, 2015, 10:52:01 AM »
I need assistance to create multiple folders at once.