1.

Solve : How to zip file one by one thru command line?

Answer»

Hi

I am having trouble to managing my disk space.

Currently i am getting file in following format.

a_011209.txt
a_021209.txt
b_011209.txt
b_021209.txt

I want to create a batch file where it will prompt me to change the date from 011209( DDMMYY format) to 021209 and then compress these files one by one.

Thanks in advance for your help.

Manoj



C:\>compact /?
Displays or alters the compression of files on NTFS partitions.

COMPACT [/C | /U] [/S[:dir]] [/A] [/I] [/F] [/Q] [filename [...]]

/C Compresses the SPECIFIED files. Directories will be marked
so that files added afterward will be compressed.
/U Uncompresses the specified files. Directories will be marked
so that files added afterward will not be compressed.
/S Performs the specified operation on files in the given
directory and all subdirectories. Default "dir" is the
current directory.
/A Displays files with the hidden or system attributes. These
files are omitted by default.
/I Continues performing the specified operation even after errors
have occurred. By default, COMPACT stops when an error is
encountered.
/F Forces the compress operation on all specified files, even
those which are already compressed. Already-compressed files
are skipped by default.
/Q Reports only the most essential information.
filename Specifies a pattern, file, or directory.

Used without PARAMETERS, COMPACT displays the compression state of
the current directory and any files it contains. You MAY use multiple
FILENAMES and wildcards. You must put spaces between multiple
parameters.

C:\>C:\>type press.bat

Code: [Select]@echo off

sed s/011209/021209/ datfile.txt


sed s/011209/021209/ datfile.txt | compact /cC:\>press.bat
a_021209.txt
a_021209.txt
b_021209.txt
b_021209.txt

Setting the directory C:\ to compress new files [OK]

Compressing files in C:\

-------------------------
rem Uncompress
rem C:\>sed s/011209/021209/ datfile.txt | compact /uNote: SED is just one of many UNIX or GNU things that have been redone for a Windows 32 bit environment.
Look here, Sed is near the bottom of the list.
http://unxutils.sourceforge.net/Quote from: Geek-9pm on December 28, 2009, 08:31:24 PM

Note: SED is just one of many UNIX or GNU things that have been redone for a Windows 32 bit environment.
Look here, Sed is near the bottom of the list.
http://unxutils.sourceforge.net/

I believe my sed version is for 32-bit and the creation date is 2005.

The simple substitution(s) of one pattern in a file name for different pattern seems to work ok.

sed s/011209/021209/ datfile.txt

p.s. I have not used 64-bit

Quote from: Geek-9pm on December 28, 2009, 08:31:24 PM
Note: SED is just one of many UNIX or GNU things that have been redone for a Windows 32 bit environment.
Look here, Sed is near the bottom of the list.
http://unxutils.sourceforge.net/

better to use GNU ones....see my sigQuote from: ghostdog74 on December 28, 2009, 09:50:24 PM
better to use GNU ones....see my sig
Thanks, my beady LITTLE eyes did not see that before.
Here is the link in big letters.
http://gnuwin32.sourceforge.net/packages.html


Discussion

No Comment Found