7-Zip rename root folder in a zip from command line - command-line

I’m using 7-Zip to create a .zip file from command line.
I have this directory structure D:\TEST\ROOT_FOLDER\ now I want to create zip file that include all files under ROOT_FOLDER and also that the root folder name in the zip will be ROOT instead of ROOT_FOLDER.
Currently I set the working directory to D:\TEST and then run this, from what I see rn command is only used to rename files not folders, so it there a way to do what I want ?
7z.exe a -r D:\\TEST.zip ROOT_FOLDER\*

Related

How to zip a list of files of the same type using jar command

I have a folder on my computer at the following path:
/path/to/folder/
This folder contains a subfolder and many cvs files
folder/subfolder
folder/1.cvs
folder/2.cvs
...
folder/n.cvs
Now, I would like to be able to zip all the .cvs files into one .zip file using the jar command (long story...)
The best I could come up with is:
jar -cvfM output.zip -C /path/to/folder .
This works, but inside output.zip I also see the subfolder, is there any way to avoid it? I tried using the * wildcard like this:
jar -cvfM output.zip -C /path/to/folder *.cvs
But it doesn't work.
Is it possible?
Thanks in advance

Is there a way to archiving using 7 zip CLI and exclude a particular folder using full paths?

I am on windows 10, and I'm struggling to exclude a directory from archive using the 7z CLI
Archive directory: D:/
zip file: C:/users/hamster/desktop/archive.zip
exclude folder: D:/movies
Command:
C:\Program Files\7-Zip\7z.exe a -mhe -p{password} c:/users/hamster/desktop/archive.zip D:/ -x!D:/movies
7z still archives the movies directory. Any help is appreciated.
I found that the -x flag only works with relative paths by default. I included the -spf2 flag to allow full paths. I also added the * wildcard to capture all files and folders within the directory.
So the new command is as follow:
C:\Program Files\7-Zip\7z.exe a -mhe -p{password} -spf2 c:/users/hamster/desktop/archive.zip D:/ -x!D:/movies/*

command prompt: how would you move subfolders to parent folder?

I want to move whole folders instead of files inside the subfolder. I tried MOVE command but I can only move files. Is there any other command?
Assuming you're on Windows:
You may need to move the contents of the folder to another folder:
To move one or more files:
MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination
example:
move c:\windows\temp\*.* c:\temp
Move the files of c:\windows\temp to the temp directory in root, this is of course assuming you have the Windows\temp directory. In this example, . is wildcards telling the computer every file with every extension.
Source: http://www.computerhope.com/movehlp.htm
Alternately, this SO question's answers may help you: Command Prompt: Why do I get “cannot find the path specified” when I move a folder (with contents) from the desktop to a new directory?

How to move a .tar.gz file from one directory to another directory

i have a file latest.tar.gz i have to move this file to another folder.
example: file is in this path root/home/phani
i have to move this file to root/san/newwebsite/
am new to centOS pls help me grt out of from this.
In a shell window, type:
mv /root/home/phani/latest.tar.gz /root/san/newwebsite/

How to include files and folders with 7zip powershell

Im trying to make my powershell script zip up a few files and folders. At the moment I can make my script either zip all files (with no folders included), or zip all files with folders included but to the wrong path.
An example would be if I have a folder named wordpress with files and a few subfolders. I need my zip file to be wordpress.zip, with all files and subfolders being in the root of that zip as opposed to \wordpress\files.*
Any help would be appreciated. Here is my code so far
function create-7zip([String] $aDirectory, [String] $aZipfile){
[string]$pathToZipExe = "C:\Program Files\7-zip\7z.exe";
[Array]$arguments = "a", "-tzip", "$aZipfile", "$aDirectory";
& $pathToZipExe $arguments;
}
create-7zip "$storageDir\wordpress\*.*" "$storageDir\wordpress.zip"
The above example will only zip files inside of my target folder, I need it to include the subfolders as well.
create-7zip "$storageDir\wordpress\*" "$storageDir\wordpress.zip"
will include files and subfolders.