Hi
I am trying to use 7zip with QM.I would like to zip selected files from file explorer. I created a string with the paths.
str ft
I checked the string during the process , it looks good.
When i put the whole path in the command line the zip file is correct.
RunConsole2 "C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z C:\Users\123\Downloads\wn.txt"
When I substitute the whole path with the string in the command line it is creating an empty zip file.
RunConsole2 "C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z ft"
I am attaching the macro.
Can somebody help me please?
Thanks
TNH
str ft
find Windows Explorer window
int hwnd=win("" "ExploreWClass")
if(!hwnd) hwnd=win("" "CabinetWClass")
if(!hwnd) end "folder window not found"
Get ShellBrowserWindow interface by enumerating shell windows
SHDocVw.ShellWindows sw._create
SHDocVw.ShellBrowserWindow b
foreach(b sw)
int hwnd2=b.HWND; err continue
if(hwnd=hwnd2) goto g1
ret
g1
get shell folder view document
Shell32.ShellFolderView sfw=b.Document
Shell32.FolderItem fi
enumerate selected items
foreach fi sfw.SelectedItems
fi.Path
ft.addline(fi.Path)
out ft
RunConsole2 "C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z ft"
07-24-2018, 12:00 AM (This post was last modified: 07-24-2018, 12:31 AM by Kevin.)
something like this should work
need to format ft into other string
otherwise its just the letters ft
cant test dont have 7zip .
as an alternative you could just use qm and zip the files in regular zip format
str ft ;find Windows Explorer window int hwnd=win("""ExploreWClass") if(!hwnd) hwnd=win("""CabinetWClass") if(!hwnd)end"folder window not found" ;Get ShellBrowserWindow interface by enumerating shell windows SHDocVw.ShellWindows sw._create SHDocVw.ShellBrowserWindow b foreach(b sw) ,int hwnd2=b.HWND ,err ,,continue ,if(hwnd=hwnd2) ,,goto g1 ,;ret ;g1 ;get shell folder view document Shell32.ShellFolderView sfw=b.Document Shell32.FolderItem fi ;enumerate selected items foreach fi sfw.SelectedItems ,fi.Path ,ft.addline(fi.Path) ,out ft str check.format("C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z %s" ft) out check outF"C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z {ft}" ;possible ways to run uncomment to test(to uncomment right click on the line number) ;RunConsole2 check ;RunConsole2 F"C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z {ft}"
str check.format("C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z %s" ft)
out check
out F"C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z {ft}"
possible ways to run uncomment to test
RunConsole2 check
RunConsole2 F"C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z {ft}"
I works with one file.
When i select a couple files it only zip the last one.
str ft ;find Windows Explorer window int hwnd=win("""ExploreWClass") if(!hwnd) hwnd=win("""CabinetWClass") if(!hwnd)end"folder window not found" ;Get ShellBrowserWindow interface by enumerating shell windows SHDocVw.ShellWindows sw._create SHDocVw.ShellBrowserWindow b foreach(b sw) ,int hwnd2=b.HWND ,err ,,continue ,if(hwnd=hwnd2) ,,goto g1 ,;ret ;g1 ;get shell folder view document Shell32.ShellFolderView sfw=b.Document Shell32.FolderItem fi ;enumerate selected items foreach fi sfw.SelectedItems ,fi.Path ,ft.addline(fi.Path) out ft str zf="$desktop$\test.zip";;; change to your desired directory and zip name str fn out"zip" zip zf ft 0 fn if(fn.len)out fn
str ft ft2 ;find Windows Explorer window int hwnd=win("""ExploreWClass") if(!hwnd) hwnd=win("""CabinetWClass") if(!hwnd)end"folder window not found" ;Get ShellBrowserWindow interface by enumerating shell windows SHDocVw.ShellWindows sw._create SHDocVw.ShellBrowserWindow b foreach(b sw) ,int hwnd2=b.HWND;errcontinue ,if(hwnd=hwnd2)goto g1 ret ;g1 ;get shell folder view document Shell32.ShellFolderView sfw=b.Document Shell32.FolderItem fi ;enumerate selected items int i foreach fi sfw.SelectedItems ,if i=0 ,,ft2=fi.Path ,,ft+ft2 ,else ,,ft2=fi.Path ,,ft +"," ,,ft+ft2 ,i +1 ;out ft str check.format("C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z %s" ft) ;out check ;out F"C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z {ft}" ;possible ways to run uncomment to test(to uncomment right click on the line number) ;RunConsole2 check ;RunConsole2 F"C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z {ft}" ;RunConsole2 "C:\7-Zip\7zg.exe a C:\Users\123\Downloads\test.7z ft"
07-24-2018, 03:16 AM (This post was last modified: 07-24-2018, 05:27 AM by Kevin.)
yes i figured that out as well found 7zip on my old win7pc and tested
A couple of notes on this, 7zip has trouble with filenames or folder names that have spaces in them. Also you should be using 7z.exe(Command line version) with RunConsole2 as you can see the output in qm and is alot faster .7zG.exe does work but is slower and if there is problems using 7zG.exe the qm macro or function will just hang and not end. updated function below
str ft ft2 foldername filename archive ;find Windows Explorer window int hwnd=win("""ExploreWClass") if(!hwnd) hwnd=win("""CabinetWClass") if(!hwnd)end"folder window not found" ;Get ShellBrowserWindow interface by enumerating shell windows SHDocVw.ShellWindows sw._create SHDocVw.ShellBrowserWindow b foreach(b sw) ,int hwnd2=b.HWND;errcontinue ,if(hwnd=hwnd2)goto g1 ret ;g1 ;get shell folder view document Shell32.ShellFolderView sfw=b.Document Shell32.FolderItem fi ;enumerate selected items int i foreach fi sfw.SelectedItems ,if i=0 ,,ft2=fi.Path ,,ft+ft2 ,else ,,ft2=fi.Path ,,ft +" " ,,ft+ft2 ,i +1 ;out ft
foldername="C:\Users\123\Downloads\";;location of folder of saved archive
filename="test.7z";;possible formats 7z, XZ, BZIP2, GZIP, TAR, ZIP and WIM
archive.format("C:\7-Zip\7z.exe a %s%s %s" foldername filename ft) RunConsole2 archive out"done" run foldername;; open folder where archive is created