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

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/*

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

7-Zip rename root folder in a zip from 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\*

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?

Accessing folders via MATLAB

I am trying to access some .m folders that I have downloaded into Downloads. How can I access this folder and run the files using cd similar to how I would on a Terminal (MacOS)? The same statements don't work.
All of the regular commands for linux should work.
ls, dir, cd 'your folder goes here' , cd ,, , cd.. etc
You need to pass the absolute path of your Downloads folder, e.g.:
current_dir = pwd;
cd('C:\Users\you_username\Downloads')
Then, you'll be able to access the files in that folder. When you are finished, you can then return to your original folder with:
cd(current_dir);
An alternative is to add the Downloads folder to your MATLAB path with addpath. You should then be able to access files in there from any directory of your choosing without having to cd. If you want to make that change to the MATLAB path permanent, use savepath afterwards to save the MATLAB path for future sessions.

Weird java.net.SocketException Permission Denied connect error when running Groovy in Intellij IDEA

When running a VERY simple URL grab script from within IntelliJ IDEA, I get:
java.net.SocketException: Permission denied: connect
but when I run it from the Groovy Console, it works just fine.
Here is the full script:
def data = new URL("http://wisc.edu").getText()
and here is the full console output from IntelliJ:
"C:\Program Files\Java\jdk1.7.0_01\bin\java" "-Dtools.jar=C:\Program Files\Java\jdk1.7.0_01\lib\tools.jar" "-Dgroovy.home=C:\Program Files (x86)\Groovy\Groovy-1.8.2" "-Dgroovy.starter.conf=C:\Program Files (x86)\Groovy\Groovy-1.8.2\conf\groovy-starter.conf" -Didea.launcher.port=7534 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 110.492\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\groovy-1.8.2.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 110.492\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.groovy.tools.GroovyStarter --conf "C:\Program Files (x86)\Groovy\Groovy-1.8.2\conf\groovy-starter.conf" --main groovy.ui.GroovyMain --classpath "C:\Users\[REDACTED]\IdeaProjects\test\out\production\test;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\ant-1.8.2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\ant-antlr-1.8.2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\ant-junit-1.8.2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\ant-launcher-1.8.2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\antlr-2.7.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\asm-3.2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\asm-analysis-3.2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\asm-commons-3.2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\asm-tree-3.2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\asm-util-3.2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\balloontip-20090102.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-anim-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-awt-util-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-bridge-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-codec-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-css-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-dom-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-ext-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-extension-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-gui-util-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-gvt-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-parser-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-script-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-svg-dom-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-svggen-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-swing-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-transcoder-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-util-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\batik-xml-1.7.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\bsf-2.4.0.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\commons-cli-1.2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\commons-logging-1.1.1.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\cssbuilder-0.5.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\cssparser-0.9.5.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\easyb-0.9.8.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\extra166y-1.7.0.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\flamingo-4.1.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\flamingobuilder-0.4.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\forms-1.2.1.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\gant-1.9.6_groovy-1.8.1.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\gfxbuilder-core-0.5.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\gfxbuilder-svg-0.5.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\gfxbuilder-swingx-0.5.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\gmock-0.8.1.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\gpars-0.12.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\groovy-1.8.2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\groovypp-0.9.0_1.8.2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\groovyserv-0.9.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\ivy-2.2.0.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\jacob-1.14.3.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\jansi-1.6.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\jcsp-1.1-rc5.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\jide-oss-2.9.1.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\jidebuilder-4.0.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\jline-0.9.94.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\jna-3.2.2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\jsilhouette-geom-0.4.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\jsp-api-2.0.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\jsr166y-1.7.0.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\junit-4.8.2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\l2fprod-common-all-6.9.1.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\macwidgets-0.9.4.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\macwidgetsbuilder-0.4.1.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\maven-ant-tasks-2.1.0.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\multiplegradientpaint-1.0.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\multiverse-beta-0.7-RC-1.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\netty-3.1.5.GA.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\sac-1.3.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\scriptom-1.6.0.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\scriptom-ie-6-tlb-1.6.0.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\scriptom-office-2K3-tlb-1.6.0.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\scriptom-sapi-tlb-1.6.0.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\scriptom-scripting-tlb-1.6.0.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\scriptom-wbem-tlb-1.6.0.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\scriptom-wsh-tlb-1.6.0.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\servlet-api-2.4.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\spock-core-0.6-groovy-1.8-SNAPSHOT.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\swing-worker-1.1.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\swingx-beaninfo-1.6.2-2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\swingx-core-1.6.2-2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\swingxbuilder-0.1.8.1.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\swingxtrasbuilder-0.3.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\timingframework-1.0.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\trident-6.2.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\tridentbuilder-0.5.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\xml-apis-ext-1.3.04.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\xmlpull-1.1.3.1.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\xstream-1.4.1.jar;C:\Program Files (x86)\Groovy\Groovy-1.8.2\lib\xswingx-0.2.jar" --encoding=UTF-8 C:\Users\[REDACTED]\IdeaProjects\test\test.groovy
Caught: java.net.SocketException: Permission denied: connect
java.net.SocketException: Permission denied: connect
at test.run(test.groovy:9)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Process finished with exit code 1
I have absolutely no idea what is causing the problem, but my guess is that it's something IDEA is doing when it runs the groovy code that keeps it from being able to access the network.
Has anyone else experienced this? Does anyone know of a workaround?
There is a known bug in JDK 1.7 related to IPv6.
Adding -Djava.net.preferIPv4Stack=true in VM Options should fix the problem.
See also related question on this site.
Even though it's an old and accepted answer, I faced same issue with java 1.8 and IntelliJ Idea21, I found it difficult to find the right VM Option file to be updated the -Djava.net.preferIPv4Stack=true in VM Options
The correct location of the file for my idea installation is,
IDE_HOME\bin<product>[bits][.exe].vmoptions file (C:\ideaIC-2021.3.3.win\bin\idea64.exe.vmoptions)
Just editing and adding VM Option through Help -> Edit Custom VM Options didn't help
https://intellij-support.jetbrains.com/hc/en-us/articles/206544869-Configuring-JVM-options-and-platform-properties