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

Archive each file to separate file in its own folder

(1/3) > >>

menych:
WinRAR has a great function that allows archiving multiple files each to its own archive.

Unfortunately, it saves all of these archives to a single folder, which kind of defeats the purpose of this functionality for me.

What I want is do be able to:

1. Select multiple files in various folders on my computer (I will be using Everything search for that);
2. Either drag-and-drop them or right-click-menu them to a program that would zip each of these files separately with a predefined password, save each file to the same folder as the original, and delete the original.

For example, if I selected:

e:\some folder\@and one more folder@@@\file1.docx
d:\some folder\@and one more folder@@@\file23 34.exe
e:\some folder\@and one more folder@@@\file23 34.docx

I would like the program (let's call it tmfzip.exe) to read the contents of the tmfpass.txt file in the same folder as tmfzip.exe, and save password-protected archives as:

e:\some folder\@and one more folder@@@\file1.zip
d:\some folder\@and one more folder@@@\file23 34.zip
e:\some folder\@and one more folder@@@\file23 34.zip

and then delete the originals.

Can you please help?

Lintalist:
If you don't mind using AutoHotkey - http://autohotkey.com - you can use this script. It assumes the command line rar.exe is somewhere in your PATH. If you don't want to use or install AutoHotkey.exe you can compile the script into a Standalone exe (just remember that your password will not be protected by compiling the script). You can alter the script to read the password from an Ini file for example or ask the user to enter the password using a simple InputBox command.

--- ---#NoEnv
SetBatchLines, -1

if not A_IsAdmin
{
   Run *RunAs "%A_ScriptFullPath%"  ; Requires v1.0.92.01+
   ExitApp
}

; ----------

Password:="MyPassword"

#IfWinActive ahk_exe everything.exe
#z:: ; Winkey-z(ip)
ClipboardSave:=ClipboardAll
Clipboard:=""
; Ctrl-Shift-C = Copy full name to Clipboard
Send ^+c
ZipTheseFiles:=Clipboard
Clipboard:=ClipboardSave
ClipboardSave:=""
Loop, parse, ZipTheseFiles, `n, `r
{
SplitPath, A_LoopField, OutFileName, OutDir, , OutNameNoExt
; a is just archiving, replace 'a' with 'm' if you want to delete (move) the files after creating the rar
RunWait, %comspec% /c rar.exe a -ep -p%Password% "%OutDir%\%OutFileName%.rar" "%A_LoopField%",,Hide
}
MsgBox Done!
Return

menych:
Thank you so much for your help.

I've just installed AHK.

I've never used it before, so I'm a bit lost...

I copied your script into autohotkey.ahk and ran the program, but nothing seems to happen other than I'm getting the following output:


--- ------- C:\Users\Unomyname\Documents\AutoHotkey.ahk
002: SetBatchLines,-1
004: if not A_IsAdmin 
012: Password := "MyPassword"
015: Return (3.38)

How do I actually use it?

Thanks again

Lintalist:
The script actually checks if Everything is the active window. If it is you can press the Windows key + Z shortcut that will copy the paths of the selected files to the clipboard and then rar each selected file into its own RAR file.

At the moment it just archives them so you can test it out, if you're satisfied with the results of the script you can repalce the 'a' with 'm' so it will move the files to the archive.

See the RAR command line help for more info and options http://ss64.com/bash/rar.html

menych:
OK,

So I select files in Everything, press Win-Z, I get the Done message box, but no archives are created.

I tried playing around with rar.exe in the ahk file by changing call with rar.exe to:


--- ---RunWait, %comspec% /c C:\Program Files\WinRAR\Rar.exe a -ep -p%Password% "%OutDir%\%OutFileName%.rar" "%A_LoopField%",,Hide
and


--- ---RunWait, %comspec% /c "C:\Program Files\WinRAR\Rar.exe" a -ep -p%Password% "%OutDir%\%OutFileName%.rar" "%A_LoopField%",,Hide
But the archives are still not being created.

I love the algorithm you came up with. It's brilliant. Now, we have to make sure that the commands are reaching the rar.exe, which I suspect they don't.

Is there something I can do to debug?

Navigation

[0] Message Index

[#] Next page

Go to full version