Page 1 of 1

Zip the file and ask for password in a single shortcut key?

Posted: 01 Mar 2024 06:18
by shamsudeen
Hi folks, how are you doing. ?

I need to make a repetitive task, that is, drag and drop a file into the WinRAR application and click Create Password, then type the password for that file. This is my repetitive task.

Is there a way to make a single shortcut key? When I press the shortcut key, it should zip and wait for me to enter my password. ?

Thank you, guys

Re: Zip the file and ask for password in a single shortcut key?

Posted: 01 Mar 2024 07:05
by highend
Ofc this is not possible, XY doesn't support drag'n drop automation

You are free though to use input() and the winrar command line to do the same without a gui...

Re: Zip the file and ask for password in a single shortcut key?

Posted: 01 Mar 2024 08:39
by shamsudeen
thank for your reply.

but i am not going to drag and drop on xyplorer.

currently i am working like Opened winrar application in my left side screen , and on my right side screen i keep my windows xplorer, i drag and drop a pdf file to winrar, the Winrar automatically pop up for zip and i click to set password. this is what i am doing now.

but i want to make this easy in my xyplorer, click on that folder or file, and press the short cut key to zip and ask for password for the zip file. is this possible to make it. thanks

Re: Zip the file and ask for password in a single shortcut key?

Posted: 01 Mar 2024 09:21
by highend
Read the second part of my first post again

Re: Zip the file and ask for password in a single shortcut key?

Posted: 01 Mar 2024 09:32
by shamsudeen
hi,
i dont understand this, i am not familiar with script or something. can you explain me please?
You are free though to use input() and the winrar command line to do the same without a gui...
can you explain me please?

Re: Zip the file and ask for password in a single shortcut key?

Posted: 01 Mar 2024 10:35
by highend

Code: Select all

    $dst = "E:\file done";
    $rar = "C:\Program Files\WinRAR\WinRar.exe";

    end (exists($rar) != 1), quote($rar) . <crlf 2> . "does not exist, aborted!";
    end (!<curitem>), "No item selected, aborted!";

    $drv = gettoken($dst, 1, ":") . ":\";
    end (exists($drv) != 2), "Drive " . quote($drv) . <crlf 2> . "does not exist, aborted!";
    if (exists($dst) != 2) { new($dst, "dir"); }

    $base = gpc(<curitem>, "base");
    $pass = input("Input encryption pw");
    $opts = ($pass != "") ? "a -afzip -ep1 -p" . quote($pass) : "a -afzip -ep1";

    run lax("$rar" $opts "$dst\$base" "<curitem>"), "%TEMP%";

Re: Zip the file and ask for password in a single shortcut key?

Posted: 01 Mar 2024 11:08
by shamsudeen
Thank for the Script, but this is not working as expected. when i run the script it is asking for the password, after entering the password
the file created in e drive, but its removed the original file extension, and not a zip file, please check and help..

Re: Zip the file and ask for password in a single shortcut key?

Posted: 01 Mar 2024 11:21
by highend

Code: Select all

run lax("$rar" $opts "$dst\$base.zip" "<curitem>"), "%TEMP%";
Replace the original line

Re: Zip the file and ask for password in a single shortcut key?

Posted: 01 Mar 2024 18:53
by shamsudeen
hi, bro thank you very much, its working as a charm.
sorry for the delayed reply. i got outside of our office.
Thank you

Re: Zip the file and ask for password in a single shortcut key?

Posted: 01 Jan 2025 02:29
by shamsudeen
Hi brother, how to make this script to set a default single password and zip the file automatically?

Thank you

$dst = "E:\file done";
$rar = "C:\Program Files\WinRAR\WinRar.exe";

end (exists($rar) != 1), quote($rar) . <crlf 2> . "does not exist, aborted!";
end (!<curitem>), "No item selected, aborted!";

$drv = gettoken($dst, 1, ":") . ":\";
end (exists($drv) != 2), "Drive " . quote($drv) . <crlf 2> . "does not exist, aborted!";
if (exists($dst) != 2) { new($dst, "dir"); }

$base = gpc(<curitem>, "base");
$pass = input("Input encryption pw");
$opts = ($pass != "") ? "a -afzip -ep1 -p" . quote($pass) : "a -afzip -ep1";

run lax("$rar" $opts "$dst\$base.zip" "<curitem>"), "%TEMP%";

Re: Zip the file and ask for password in a single shortcut key?

Posted: 02 Jan 2025 05:13
by jupe

Code: Select all

  $pass = "PASSWORD";
  $dst  = "E:\file done";
  $rar  = "C:\Program Files\WinRAR\WinRAR.exe";

  end (exists($rar) != 1), quote($rar) . <crlf 2> . "does not exist, aborted!";
  end (!<curitem>), "No item selected, aborted!";
  
  $drv = gpc($dst, "drive") . ":\";
  end (exists($drv) != 2), "Drive " . quote($drv) . <crlf 2> . "does not exist, aborted!";
  if  (exists($dst) != 2) { new($dst, "dir"); }

  run lax("$rar" a -afzip -ep1 -p"$pass" "$dst\<curbase>.zip" "<curitem>"), "%TEMP%";

Re: Zip the file and ask for password in a single shortcut key?

Posted: 04 Jan 2025 05:11
by shamsudeen
Thank you Jupe. it works well

Thanks for the community.

Re: Zip the file and ask for password in a single shortcut key?

Posted: 11 Aug 2025 20:15
by shamsudeen
jupe wrote: 02 Jan 2025 05:13

Code: Select all

  $pass = "PASSWORD";
  $dst  = "E:\file done";
  $rar  = "C:\Program Files\WinRAR\WinRAR.exe";

  end (exists($rar) != 1), quote($rar) . <crlf 2> . "does not exist, aborted!";
  end (!<curitem>), "No item selected, aborted!";
  
  $drv = gpc($dst, "drive") . ":\";
  end (exists($drv) != 2), "Drive " . quote($drv) . <crlf 2> . "does not exist, aborted!";
  if  (exists($dst) != 2) { new($dst, "dir"); }

  run lax("$rar" a -afzip -ep1 -p"$pass" "$dst\<curbase>.zip" "<curitem>"), "%TEMP%";
@jupe
@highend
hi, how to add many files at once and run this script to zip and passoword the files seperately at once. Thank you

Re: Zip the file and ask for password in a single shortcut key?

Posted: 13 Aug 2025 12:57
by highend
By looping over them?

Code: Select all

    $pass = "PASSWORD";
    $dst  = "E:\file done";
    $rar  = "C:\Program Files\WinRAR\WinRAR.exe";

    end (exists($rar) != 1), quote($rar) . <crlf 2> . "does not exist, aborted!";
    $items = <get SelectedItemsPathNames>;
    end (!$items), "No item(s) selected, aborted!";

    $drv = gpc($dst, "drive") . ":\";
    end (exists($drv) != 2), "Drive " . quote($drv) . <crlf 2> . "does not exist, aborted!";
    if  (exists($dst) != 2) { new($dst, "dir"); }

    foreach($item, $items, <crlf>, "e") {
        $base = gpc($item, "base");
        run lax("$rar" a -afzip -ep1 -p"$pass" "$dst\$base.zip" "$item"), "%TEMP%";
    }

Re: Zip the file and ask for password in a single shortcut key?

Posted: 18 Aug 2025 04:10
by shamsudeen
highend wrote: 13 Aug 2025 12:57 By looping over them?

Code: Select all

    $pass = "PASSWORD";
    $dst  = "E:\file done";
    $rar  = "C:\Program Files\WinRAR\WinRAR.exe";

    end (exists($rar) != 1), quote($rar) . <crlf 2> . "does not exist, aborted!";
    $items = <get SelectedItemsPathNames>;
    end (!$items), "No item(s) selected, aborted!";

    $drv = gpc($dst, "drive") . ":\";
    end (exists($drv) != 2), "Drive " . quote($drv) . <crlf 2> . "does not exist, aborted!";
    if  (exists($dst) != 2) { new($dst, "dir"); }

    foreach($item, $items, <crlf>, "e") {
        $base = gpc($item, "base");
        run lax("$rar" a -afzip -ep1 -p"$pass" "$dst\$base.zip" "$item"), "%TEMP%";
    }
Thank you