Catalog item to create zip from selected files

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
nsyrax
Posts: 39
Joined: 03 Apr 2015 15:51

Catalog item to create zip from selected files

Post by nsyrax »

Is there an easy way to create a catalog item to create a zip file by dragging files onto it? Ideally, it would prompt for a file name, but if I could set one by default, that would be fine as well.

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Catalog item to create zip from selected files

Post by highend »

Sure, script it. get("drop") contains the items that are dragged over
an entry in the catalog.
One of my scripts helped you out? Please donate via Paypal

nsyrax
Posts: 39
Joined: 03 Apr 2015 15:51

Re: Catalog item to create zip from selected files

Post by nsyrax »

Please excuse my n00bness, but not exactly sure how to set this up. Any additional info would be VERY welcomed!

[UPDATE] I found your post with the script below

Code: Select all

$zip = "<path to 7-zip>\7zG.exe";
    $sel = quote(get("SelectedItemsPathNames", '" "'));
    $cnt = get("CountSelected");
    if ($cnt > 1) { $zipName = "<curpath>\" . trim(gpc(<curpath>, "base"), ":", "R") . ".7z"; }
    elseif ($cnt == 1) { $zipName = gpc(<curitem>, "base") . ".7z"; }
    else { status "No item(s) selected, aborted!", "8B4513", "stop"; end true; }
    run """$zip"" a ""$zipName"" -ad $sel", , 0, 1;
and it seems to work, but is there a way to do it without any dialog?

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Catalog item to create zip from selected files

Post by highend »

What dialog? 7z's? There is zip_add(). And that script doesn't work by
dragging but by selected items (if this makes a difference...)
One of my scripts helped you out? Please donate via Paypal

nsyrax
Posts: 39
Joined: 03 Apr 2015 15:51

Re: Catalog item to create zip from selected files

Post by nsyrax »

My mistake. Disregard the 7zip script.

nsyrax
Posts: 39
Joined: 03 Apr 2015 15:51

Re: Catalog item to create zip from selected files

Post by nsyrax »

Back to the original ask, I added the get("drop") script, but it doesn't seem to actually do anything.

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Catalog item to create zip from selected files

Post by highend »

Code: Select all

    $items = <get drop |>;
    $name  = input("Enter .zip file name", ".zip will be added automatically!", gpc(gettoken($items, 1, "|"), "base"));
    if (substr($name, -4) UnLikeI ".zip") { $name .= ".zip"; }
    zip_add("<curpath>\$name", $items);
One of my scripts helped you out? Please donate via Paypal

nsyrax
Posts: 39
Joined: 03 Apr 2015 15:51

Re: Catalog item to create zip from selected files

Post by nsyrax »

Perfect! Many thanks!

Post Reply