Unzipping zipped dstream packages - solaris

How to unzip the .dstream.Z package in Sun Solaris. I tried all the methods as under
gunzip
# gunzip pkg#1821417#27528.dstream.Z
gzip: pkg#1821417#27528.dstream.Z: not in gzip format
unzip
# unzip pkg#1821417#27528.dstream.Z
Archive: pkg#1821417#27528.dstream.Z
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of pkg#1821417#27528.dstream.Z or
pkg#27528.dstream.Z.zip, and cannot find pkg#1821417#27528.dstream.Z.ZIP, period.
jar
jar xf pkg#1821417#27528.dstream.Z
bash: jar: command not found
cpio
# cpio -idvu pkg#1821417#27528.dstream.Z
Here I had to press Ctrl+C as nothing print out.
Furthermore, I checked with file command:
# file pkg#1821417#27528.dstream.Z
pkg#1821417#27528.dstream.Z: html document

You should uncompress for such file with .Z suffix. It is an ancient tool these days, but it still works of course.
Something like this:
uncompress pkg#1821417#27528.dstream.Z

Related

Why does cygwin zip/infozip.exe only create zips named "1.zip" when using -r or -FS?

Something seems seriously broken with infozip.exe (same as zip.exe in cygwin).
I've spent FORTY MINUTES and I can't create a zip named anything other than "1.zip" if I use -r (for a new zip) and -FS (for an existing zip)
When no zip is present, I do:
[info]zip.exe "S:\Dropbox\BACKUPS\winamp.zip" -r "C:\Program Files\winamp\"
When the zip is present, I do:
[info]zip.exe "S:\Dropbox\BACKUPS\winamp.zip" -FS -r "C:\Program Files\winamp\"
This should be the easiest thing in the world. I could do this just fine in 1990 (but they had no -FS option back then). Or using wzzip (but I don't want to; it requires an install, and has no -FS option). Or using my command-lines built-in primitive zip (has no -FS option). But I need to use infozip, because I intend to use -FS to sync only changed files to the zip file later.
Of course, -FS does the same thing: The file that is created is always s:\dropbox\backups\1.zip
The error that I get is always:
zip warning: name not matched: S:\Dropbox\BACKUPS\winamp.zip
Of course the name is not matched! I'm creating a new zip! This should be easy!
Unfortunately, only [info]zip.exe has this beahvior, and only [info]zip.exe has the -FS functionality that I need to NOT have to re-zip the whole thing every time. This is a utility that will be used for many folder backups, I don't want to re-zip every file every time.
Clarification: The zip.exe that comes with cygwin is infozip.exe.

Using command line to compress a .bak file and moving the zip file

I am trying to use command line to zip a .bak file then cut the zip file to another location or copy/paste and delete the original once the copy is complete.
Right now my script is
copy "\\a\*.bak" "\\b"
I would like to compress the .bak file (in folder a) as it is a huge file, and then CUT the zip file into folder b.
Windows has a built-in functionality for this.
tar.exe -a -c -f file_Output.zip your_file.bak
file_Output.zip will be the file you will get as your zipped file, your_file.bak will be the file you are trying to compress.

Winrar CommandLine & Powershell : Exclude Full Directory Path Structure

Suppose I have a directory structure like
C:\Users\Desktop\abc\d
I want to rar archive the abc folder so that the structure of rar is:
abc\d
When I try using powershell to archive, winrar replicates the full path inside the archive, like:
\Users\Desktop\abc\d
I dont want the full path to be created inside the archive
Here's the script:
https://gist.github.com/saurabhwahile/50f1091fb29c2bb327b7
What am I doing wrong?
Use the command line:
Rar.exe a -r -ep1 Test.rar "C:\Users\Desktop\abc"
Rar.exe is the console version of WinRAR stored in same directory as WinRAR.exe. You can use this command line also with WinRAR.exe if you want to see the compression process in a graphic window.
a is the command and means add files to archive.
-r is a switch to recursively add all files and subdirectories including empty subdirectories to the archive.
-ep1 is another switch which results in execluding base directory.
For this command line the base directory is "C:\Users\Desktop\" and therefore the created archive Test.rar contains only abc and all files and subdirectories in directory abc which is what you want.
One more hint: Using the command line
Rar.exe a -r -ep1 Test.rar "C:\Users\Desktop\abc\"
results in adding all files and subdirectories of directory abc to the archive, but without directory name abc being also stored in the archive. The backslash at end makes this difference.
In other words: On using switch -ep1 everything up to last backslash in file/directory specification is not added to the archive.
For more information about available switches see the text file Rar.txt in the program files directory of WinRAR.

Change file extensions of multiple files in a directory with terminal/bash?

I'm developing a simple launchdaemon that copies files from one directory to another. I've gotten the files to transfer over fine.
I just want the files in the directory to be .mp3's instead of .dat's
Some of the files look like this:
6546785.8786.dat
3678685.9834.dat
4658679.4375.dat
I want them to look like this:
6546785.8786.mp3
3678685.9834.mp3
4658679.4375.mp3
This is what I have at the end of the bash script to rename the file extensions.
cd $mp3_dir
mv *.dat *.mp3
exit 0
Problem is the file comes out as *.mp3 instead of 6546785.8786.mp3
and when another 6546785.8786.dat file is imported to $mp3_dir, the *.mp3 is overwritten with the new .mp3
I need to rename just the .dat file extensions to .mp3 and keep the filename.
Ideas? Suggestions?
Try:
for file in *.dat; do mv "$file" "${file%dat}mp3"; done
Or, if your shell has it:
rename .dat .mp3 *.dat
Now, why your command didn't work: first of all, it is more than certain that you only had one file in your directory when it was renamed to *.mp3, otherwise mv would have failed with *.mp3: not a directory.
And mv does NOT do any magic with file globs, it is the shell which expands globs. Which means, if you had this file in the directory:
t.dat
and you typed:
mv *.dat *.mp3
the shell would have expanded *.dat to t.dat. However, as nothing would match *.mp3, the shell would have left it as is, meaning the fully expanded command is:
mv t.dat *.mp3
Which will create a file named, literally, *.mp3.
If, on the other hand, you had several files named *.dat, as in:
t1.dat t2.dat
the command would have expanded to:
mv t1.dat t2.dat *.mp3
But this will fail: if there are more than two arguments to mv, it expects the last argument (ie, *.mp3) to be a directory.
For anyone on a mac, this is quite easy if you have BREW, if you don't have brew then my advice is get it. then when installed just simply do this
$ brew install rename
then once rename is installed just type (in the directory where the files are)
$ rename -s dat mp3 *

How to extract ZIP files with WinRAR command line?

While trying to extract zip files I get the error:
c:\path\name.zip is not RAR archive
No files to extract
My code is:
p.StartInfo.FileName = #"C:\Program Files\WinRAR\rar.exe";
p.StartInfo.Arguments = string.Format("x -o- {2} \"{0}\" * \"{1}\"\\ ",
szFN,
outFolder,
passWord == null ? "" : string.Format("-p\"{0}\"", passWord));
The GUI version can extract zip and 7z files.
Why doesn't this work? How can I extract zip and 7z files?
(NOTE: I have different source code for 7zip. I guess I can merge the two and only use the above when the file has a rar extension. But I don't like that solution.)
Free unrar.exe and console versionRar.exe of WinRAR support only RAR archive format. That is clearly described in second paragraph in manual for Rar.exe which is the text file Rar.txt in program files folder of WinRAR.
You need to use WinRar.exe instead which supports also other archive formats:
[path\winrar.exe] x [switches] [path to zip file] [files to extract, . for all files] [path folder to extract to]
Example:
"%ProgramFiles%\WinRAR\winrar.exe" x -ibck c:\file.zip *.* c:\folder\
The syntax, commands and switches for GUI version WinRAR.exe are listed and described in help of WinRAR. Click in menu Help on menu item Help topics, open on help tab Contents the item Command line mode and read the help pages listed under this item.
For example the switch -ibck supported only by WinRAR.exe but not by Rar.exe is for running the extraction in background which means GUI version of WinRAR makes the extraction minimized to an icon in Windows system tray.
rar.exe can indeed only unpack rar files. It's not at all the same as WinRAR.
For unpacking ZIP files in .NET, you might want to look at the DotNetZip library instead. It has a license compatible with commercial software, unlike CSharpZipLib.
If you need to support RAR as well, you can use UnRAR.dll with pinvoke:
http://www.rarlab.com/rar_add.htm
http://www.rarlab.com/rar/UnRARDLL.exe
Or this .NET unRAR libary:
http://www.chilkatsoft.com/rar-dotnet.asp
Perhaps this one for 7zip.
You can use either SevenZipSharp or DotNetZip Library in your Application!
But I will go for SevenZipSharp Lib as It supports all the archives supported by 7-Zip!
Both Source and Binary are available in the Links!
for /f "tokens=*" %G in ('dir /on /b "D:\BACKUP_DATI\EXCEL\OPER*.ZIP"') do "C:\Program Files\7-Zip\7z.exe" x "..\%G" –aoa
References to further reading:
7-Zip command line examples
FOR /D - Loop through directory