I am trying to append a script in my JAVA program to unzip the files in specific folder by 7z. Here come below script. But I found that it will also extract the .zip files in subfolder.
7z e -aoa -ppassword c:\xxx\desktop\fromFolder -oc:\xxx\desktop\toFolder > nul:
What if I want to extract the .zip files located in "fromFolder" only and exclude all files in the subfolders of "fromFolder". Please advice, thanks.
Related
I have a folder structure like this:
Folder
- Sub-folder
- Sub-folder
- Archive
- Archive
- Sub-folder
- Sub-folder
- Archive
- Archive
I would like to extract all archives in all sub-folders.
When extracting an archive I want the files to extract in the same directory as where the archive is located then once it is completed extracting I would like to delete the archive.
I am trying to do this with 7zip from the command line using zip files.
I have got as far as this: 7za x -tzip -r -o "C:\Users\nath1\Downloads\testing"
Any help would be much appreciated.
I wanted to know how to move files to a .zip archive. I'm using this code: xcopy C:\Folder C:\AnotherFolder\zippedFolder.zip. This copies the files from C:\Folder DIRECTLY into the archive, but I want to have that file in the archive (so i can doubleclick the archive and see the file unopened).
Want to do this to create an excel file with a .cmd
Use -m to import a file to a ZIP archive.
I found this on StackOverflow maybe it helps you.
How to move a file in to zip uncompressed, with zip cmd tool
But be careful it deletes the source file after it adds it to the archive. See the link for more details.
UPDATE
Instructions from this site. http://linux.about.com/od/commands/l/blcmdl1_zip.htm.
-m moves the specified files into the ZIP archive; actually, this deletes the target directories/files after making the specified ZIP archive.
If a directory becomes empty after removal of the files, the directory is also removed. No deletions are done until zip has created the archive without errors. This is useful for conserving disk space, but is potentially dangerous so it is recommended to use it in combination with -T to test the archive before removing all input files.
zip -m yourfile zip.file
We have several big sized zip files. Each of these zips contains excel file and a bunch of bmp images.
I was just wondering if 7-zip allows listing the content of the zip without unzipping it? And also if we can selectively unzip the excel file?
Currently, I use c# console program utilizing diagnostic process to execute 7z.exe. It would be nice not to unzip the entire thing.
For listing you can use the list command (l) to the 7zip.exe
7z l archive.zip
For selectively extracting files you can use different commands to the extract command. Something like:
7z e archive.zip -oc:\soft *.xls
I would like to be able to copy all files from various folders and combine them into a single folder using a Windows batch file. That is fairly easy to do for me. But if the file already exists on the destination, I would like it to only override the file if it's newer.
copy c:\pics\ to d:\
Thanks.
You can use xcopy for more options if the source dirs are 2-3-5 (write separate xcopy lines for each). If the dirs are too many, you can use archiver like WinRar (or its command line rar.exe) with #list option where are stored the source dirs. In the batch file call RAR 2 times - first to pack all source files to one archive, then to unrar them in single folder (with E option, not X). Finally, you delete the .rar file. See the extra options to skip older files, omit prompts, etc.
I need some help with a batch file because I am stumped on WinRAR in Batch, as I haven't done/used it before.
Here is the TREE of my Folders including the batch file:
Each RAR file has the same Directory folder name("vegies" folder).
I would like to be able to extract/copy all folders/subfolders inside of each .rar from "Example/Program_Ex/vegie" back one directory into "Example/Program_Ex/vegies" (Dont forget the folder "vegies" already exists in each RAR which I cannot change as these automatically update themselves.)
So basically with a batch file I would like to:
extract "Example/Program_Ex/vegie/random.rar" to "Example/Program_Ex/vegies"
extract "Example/Program_Ex/vegie/random2.rar" to "Example/Program_Ex/vegies"
extract "Example/Program_Ex/vegie/random3.rar" to "Example/Program_Ex/vegies"
extract "Example/Program_Ex/vegie/random4.rar" to "Example/Program_Ex/vegies"
extract "Example/Program_Ex/vegie/random5.rar" to "Example/Program_Ex/vegies"
I also am trying to not specify a drive, more or less because the batch file will be in the correct folder instead using something such as "CD" or "PATH"?
I have looked at some examples around the web and on here of coarse, but I am still unsure the best way to go about this.
The closest example I can find would be this:
#echo off
set destinationRAR=destination_winrar_file
set source=source_folder_path
"C:\Program Files\WinRAR\WinRAR.exe" a -ep1 -esh -ibck -m0 -r -t %destinationRAR% %source%
(Above from http://fredy-invayne.blogspot.com.au/2013/05/example-winrar-batch-file.html)
Can anyone help give examples on how to implement my question please?
#echo off
for %%a in (
"%~dp0Example\Program_Ex\vegie\*.rar"
) do unrar x "%%~fa" -w "%~dp0Example\Program_Ex" -o+
For each file in the indicated path under the folder in where the batch file is stored, extract the content of the file indicating target folder and selecting that existing files must be overwritten.
You can extract all the archives with a single invocation of WinRAR:
"C:\Program Files\WinRAR\WinRAR.exe" x "%~dp0Program_Ex\vegie\random*.rar" "%~dp0Program_Ex\"
The last argument in the above command line specifies the target folder for all the archives. You may want to add the -o+ switch (must go just after x) to specify that all files should be overwritten:
"C:\Program Files\WinRAR\WinRAR.exe" x -o+ "%~dp0Program_Ex\vegie\random*.rar" "%~dp0Program_Ex\"
If you omit it, the archiver will ask you what to do with existing files, if any.