How to extract 7zip archives with relative paths - 7zip

I have an archive myfile.7z that contains the single file
\Folder1\Folder2\Folder3\Folder4\myfile.txt
When I open this archive in 7-zip gui, navigate to Folder3, click it and click the "Extract" icon, it will correctly extract the relative path:
\Folder3\Folder4\myfile.txt
However when I run the following from command line to extract Folder3:
"C:\Program Files\7-Zip\7z.exe" x myfile.7z -r Folder1\Folder2\Folder3
Instead of extracting the relative path starting with Folder3 in the same fashion as the gui, it extracts the full path:
\Folder1\Folder2\Folder3\Folder4\myfile.txt
How do I get the command line version to extract relative paths the same way the gui does?

Related

How to use a command to list all files with full path in Mac, including files in subfolders?

Is there such a command to do this?
The expected result is a list of files from all subfolders, including the current folder:
For example, I run the command against the directory folder, the result is like:
/Users/joe/my/long/directory/structure/README.md
/Users/joe/my/long/directory/test.md
/Users/joe/my/long/directory/structure/list/test2.md

Please help me to zip files with the same name in different directories along with the path after I enter search condition in the Windows Explorer

I try to backup files by zipping the files along with path and store it in external hard drive.
When I zip the files I insist that I include the complete path of the file so that when I unzip the files , I can make the files get stored in the specified path if it all , my hard disc crashes.
When I try to search for files with the following criteria in Windows Explorer
(System.FileName: *.txt OR .doc OR .xls OR .rtf ) AND datemodified:‎10-‎03-‎2021 .. ‎06-‎07-‎2022
Whatever the results I get I right click click 7 zip and click add to (some zip file name).7z
Now when I do this I am getting the error duplicate file name on disc
Of course I will be having same file name in different directories.
Since , I am saving the path along with the file name this duplicate error should not have come.
Please help me to zip files with the same name in different directories along with the path after I enter the following search condition in the Windows Explorer
(System.FileName: *.txt OR .doc OR .xls OR .rtf ) AND datemodified:‎10-‎03-‎2021 .. ‎06-‎07-‎2022

Copy and replace multiple files (with their full path) from one directory to another directory's corresponding paths

Say I have two folders : SOURCE and DEST
I have been provided with relative path of bunch of files of SOURCE. e.g
SOURCE/A/B/C/file1.cpp
SOURCE/A/B/D/file2.cpp
SOURCE/M/B/G/file3.cpp
...
to replace the corresponding files in DEST directory
DEST/A/B/C/file1.cpp
DEST/A/B/D/file2.cpp
DEST/M/B/G/file3.cpp
...
Can I achieve this with minimal effort using command prompt?
FYI, usually I need to repeatedly go back and forth from SOURCE to DEST to copy each individual file, which is very time consuming and error prone.
There is robocopy utility, which can help you to do what you want:
robocopy <Original Folder> <Destination Folder> /mir

Double click on the zip file has to self-extract the file in the specified path

I have filename.zip file and if double click the file it has to extract the file in the desired location("c:\user\username"). I have tried using the batch file but didnt give me the required result.
#echo on
#set nested=%nested%Z
set _dest=c:\user\username
if NOT EXIST %_dest% md %_dest%
So if i double click on zip file it has to execute batch file to place file in the destination folder path.How can i do that?
If I understand correctly, you simply want to extract a .zip archive to a previously defined directory c:\user\username, when the user clicks that .zip archive.
No, this is not possible.
A .zip file has no default extraction destination. Nor has is a way to execute scripts upon extraction. It is just a container for compressed data. When you click it, your OS runs a program configured to handle .zip files, allowing you to view the contents, extract the contents, etc - but what and how exactly, is up to the user that clicked the file.
What you effectively want to have is an installer. Here are some pointers for options to do that:
Microsoft IExpress
Nullsoft Scriptable Install System (NSIS)
Quasi-installer using 7-zip self-extracting archive

How to use Windows Batch File to mass unzip files and saving them in specific folders?

I got the code to mass unzip from this link. But it unzips everything in the folder where the batchfile exists. I want it to unzip it to specific folders or its individual folders.
Note: my bz2 files are in various folders outside the folder where the batchfile exists.
Here's the script that i used :
for /R "C:\Users\victor\Desktop\MASTERS\color feret\disc 1\data\images" %%I in ("*.bz2")
do ("%ProgramFiles%\WinRAR\WinRAR.exe" x -y -o"%%~dpnI" "%%~fI")
Can someone enlighten me how to do it?
And also if possible, can anyone explain to me what are the arguments for? "x , -y -o %%dpnI " etc. Thanks
You do not need a batch file for this process at all. Start WinRAR, select all the archives you want to extract, click on Extract To in toolbar, select the base destination folder, check the option Extract archives to subfolders in Miscellaneous group and press button OK. That's it.
From a command line in a console window with current working directory being the directory containing all the *.bz2 files to extract:
"%ProgramFiles%\WinRAR\WinRar.exe" x -ad -y *.bz2 C:\Temp\
There is no need for a for loop as WinRAR supports wildcards for archive file names.
And with option -ad the archive file First.bz2 is extracted to folder C:\Temp\First, archive file Other.bz2 is extracted to C:\Temp\Other, and so on. With checking option Extract archives to subfolders in GUI, you use option -ad.
Help of WinRAR contains the page Switch -AD - append archive name to destination path. Click in menu Help on Help topics. On tab Contents open Command line mode and open Commands and Switches. Also text file Rar.txt in program files folder of WinRAR contains a description for command x and the options -ad and -y and all other commands and options for console version Rar.exe.
But if you want to use nevertheless a for loop and want to know what %%~dpnI and %%~fI mean, open a command prompt window, enter either help for or for /? and read.

Resources