Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unrar Files
In order to use this, you must have the WinRAR.exe on your computer.

Logic =
Get File Name of selected files
If the base of the file has already been processed skip the following
Run WinRAR.exe with command line parameters to extract this file in the background
Wait for unique Extracting window to appear (invisible, can see in tray)
Wait for window to disappear (completed)
Scan directory for all files with same base name and delete them.

Full list of parameters: ... swibck.htm

Function ExtractAndDelete
Trigger ^Shell_menu "ExtractAndDelete" 0x4 "rar"     Help - how to add the trigger to the macro
Copy      Help
function $files
str name
str directory
str param
str shortname
str duplicates
foreach name files
,;int i = find
,;mes name
,int rem = findr(name "\")
,directory.get(name 0 (rem+1))
,shortname.get(name (rem+2))
,int per = find(shortname ".")
,shortname.get(shortname 0 per)
,;mes shortname
,if (find(duplicates shortname) != -1)
,,out "dupe"
,duplicates + shortname
,duplicates + "[]"
,param = "x -ibck -inul -y "
,param + name
,param + " "
,param + directory
,run "$program files$\WinRAR\WinRAR.exe" param
,out param
,out "11"
,directory + "\*"
,out "directory is %s" directory
,DeleteFileFromFolder(name directory)
,out "22"

Function WaitForUnrar
Copy      Help
function ~supshort
str winname = "Extracting from "
winname + supshort
;out winname

wait 0 WC win(winname "#32770")
out "is extracting"
,int hwnd=win(winname "#32770")
,;out "is extracting";;hwnd
,if !hwnd
out "done extracting"

Function DeleteFileFromFolder
Copy      Help
function ~name ~directory

int remove = find(name "part")
if remove > -1
Dir d
foreach(d directory FE_Dir)
,if (find(d.FileName(1) name) != -1)
,,if (find(d.FileName(1) ".rar") != -1)
,,,del d.FileName(1)
,,,out d.FileName(1)

Function findr
Copy      Help
function# ~ss ~s [from];;find from back, returns position -1 if not found
;ss = "animalins"
;s = "al"
;from = 2
int total = ss.len
int tofind = s.len
int i
int temp
for i 0 (total/2)
,;out ss[i]
,temp = ss[i]
,ss[i] = ss[(total-i-1)]
,ss[(total-i-1)] = temp

for i 0 (tofind / 2)
,temp = s[i]
,s[i] = s[(tofind-i-1)]
,s[(tofind-i-1)] = temp
ss.get(ss 0 (total - from))
;out ss
int fin = find(ss s)
if fin = -1
,ret fin
;out fin
fin = total - fin - 1 - s.len
;out fin
ret fin

Similar code can be used to automatically detect when a .rar file is added to a directory, and automatically extract it if all parts are there, but my code is too computer specific as it gathers data from my Internet Download Manager(pay program) which you may or may not have, so I will not post it. If you have questions contact me on here, or on aim @ "da coo kid eric".

Forum Jump:

Users browsing this thread: 1 Guest(s)