How to compress file from a command line

U

Uzi Barzilai

On a XP machine, a file (or a folders)
can be easily compressed . (right click, send to...)

How can I do that from a command line?
I'll like to run a batch file to include moving, renaming
(I know how... old DOS commands) and compressing
(I don't know how)

Any advice?

Thanks,
Uzi
5-25-06
 
J

John John

You can use Compact.exe or Compress.exe. There is a subtle differences
between these 2 utility, for example, one will compress the file and the
other one will make a compressed copy of the file and leave the original
untouched. I'm not sure which does which, just do a search on
Microsoft.com for "Compact.exe" and "Compress.exe" and you should find
information on them.

If Compact.exe is not on your computer you should be able to extract it
from the i386 folder on your Windows XP CD. Compress.exe is a Resource
Kit utility, you can get it here:
http://www.microsoft.com/downloads/...69-57FF-4AE7-96EE-B18C4790CFFD&displaylang=en

To get information on these utilities just use the /? switch at the
command prompt, example: compact /?

John
 
G

Guest

use "compact" command


CompactDisplays and alters the compression of files or directories on NTFS
partitions. Used without parameters, compact displays the compression state
of the current directory.

Syntax
compact [{/c|/u}] [/s[:dir]] [/a] [/i] [/f] [/q] [FileName[...]]

Parameters
/c
Compresses the specified directory or file.
/u
Uncompresses the specified directory or file.
/s:dir
Specifies that the requested action (compress or uncompress) be applied to
all subdirectories of the specified directory, or of the current directory if
none is specified.

/a
Displays hidden or system files.
/i
Ignores errors.
/f
Forces compression or uncompression of the specified directory or file. This
is used in the case of a file that was partly compressed when the operation
was interrupted by a system crash. To force the file to be compressed in its
entirety, use the /c and /f parameters and specify the partially compressed
file.
/q
Reports only the most essential information.
FileName
Specifies the file or directory. You can use multiple file names and
wildcard characters (* and ?).
/?
Displays help at the command prompt.
Remarks
The compact command, the command-line version of the NTFS file system
compression feature, displays and alters the compression attribute of files
and directories on NTFS partitions. The compression state of a directory
indicates whether files added to the directory will be automatically
compressed. When you set the compression state of a directory you do not
necessarily change the compression state of files that are already there.
You cannot use compact to read, write, or mount volumes that have been
compressed using DriveSpace or DoubleSpace.
Examples
To set the compression state of the current folder and its subfolders and
existing files, from the current folder, type:

compact /c /s

To set the compression state of files in the current folder, subfolders in
the current folder, and files within all subfolders without altering the
compression state of the current folder, from the current folder, type:

compact /c /s *.*

To compress a volume, from the root folder of the volume, type:

compact /c /i /s:\

This example sets the compression state of the root folder and all folders
on the volume and compresses every file on the volume. By using the /i
parameter, you ensure that error messages do not interrupt the compression
process.

To compress all files that end in .bmp in the \Tmp directory and all
subdirectories of \Tmp, but not modify the compressed attribute of these
directories, type:

compact /c /s:\tmp *.bmp

To force complete compression of the file Zebra.bmp, which was partially
compressed at the time of a system crash, type:

compact /c /f zebra.bmp

To remove the compressed attribute from the directory C:\Tmp, but not change
the compression state of any files in that directory, type:

compact /u c:\tmp

Formatting legend
Format Meaning
Italic Information that the user must supply
Bold Elements that the user must type exactly as shown
Ellipsis (...) Parameter that can be repeated several times in a command line
Between brackets ([]) Optional items
Between braces ({}); choices separated by pipe (|). Example: {even|odd} Set
of choices from which the user must choose only one
Courier font Code or program output



for more information:
1- open help and support center "windows xp help"
2- search for "compact"
 
U

Uzi Barzilai

Thanks, John.

I have compact.exe on my machine but not compress.exe
Looking at the "switches" I think it acts on the files themselves.

I may need the "compress" as compact seems to modifies the files.
While I'll like to make a compressed copy, keep the original intact.

Looking in XP CD (I386) I can't see Compress. (Home edition)
How shall I proceed from this point?

Tx,
Uzi
 
J

John John

Download and install the Server Resource Kit, it works on XP and it's
not that big a download. I gave you the link to it in my first post.
Read the instruction on the download page. After you install the
Resource Kit, if you find that the compress.exe tool (or other tools)
doesn't work it's probably because the resource kit path is not in the
Environment Variables. If that is the case you can simply put a copy of
compress.exe in your System32 folder or add the Resource Kit to the
Environment variables. Post again if the problem occurs and someone can
help you with the Variables if need be.

John
 
U

Uzi Barzilai

Thanks, John,

I downloaded, installed & modified the path.
I compresses one file, as a test - AUTODESK.ADK
I typed: "compress -r AUTODESK.ADK"

The file AUTODESK.ADK does nor exist, now.
I have, though, AUTODESK.AD_
How do I "go back" ?
(I was expecting a .zip extension, I guess)

Uzi,
5-27-06
 
J

John John

Expand.exe

John

Uzi said:
Thanks, John,

I downloaded, installed & modified the path.
I compresses one file, as a test - AUTODESK.ADK
I typed: "compress -r AUTODESK.ADK"

The file AUTODESK.ADK does nor exist, now.
I have, though, AUTODESK.AD_
How do I "go back" ?
(I was expecting a .zip extension, I guess)

Uzi,
5-27-06
 
G

Guest

if u use win xp , u can read about "comact" command at windows help
open "help and support center" in the start menu
then ,search 4 "compact"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top