Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Command line - Some questions


  • Please log in to reply
No replies to this topic
Yaron
  • Members
  • 3 posts
  • Last active: Apr 02 2014 12:25 AM
  • Joined: 02 Apr 2014

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.