1.

Solve : extracting compressed files & dropping them into a hot folder...Questions...?

Answer»

Hi all, new here and looking for some help. This looks like a great place for info.

I receive large compressed files on a server and need a batch to extract them from that source folder (called Prod) and drop them into a destination folder (hot folder) to be processed, also place a copy in an archive folder. Problem is, if another FILE starts to come in while this one is running, it is not extracted but is moved to the archive folder (because an incomplete file can't be axtracted). How can I only extract files that have completely arrived? I would just schedule this to run every hour or a few times a day, but I have no control over the arrival times of these files, they ARRIVE at random.

Below is what I have. It works fine except it if another file comes in while this is running it gets moved to the archive folder and is not processed.

Any suggestions??


REM ***** Turn display output to off
ECHO off
REM ***** Set set prompt to "CZExtractor> "
Prompt CZExtractor$G$S
REM *****
REM *****
REM ***** clear the window and set the window colors background to 1=Blue and foreground F=Bright White
CLS
Color 1F
REM *****
ECHO **********************************************************************
ECHO See CZExtractor-readme.txt for full details on this procedure
ECHO **********************************************************************
REM *****
REM ***** Set the environment variables for the SouRCe Drive and Directory
Set CZE-SRCDRV=Q:
Set CZE-SRCDIR=\Prod
REM *****
REM ***** Set the environment variables for the ARChive Drive and Directory
Set CZE-ARCDRV=Q:
Set CZE-ARCDIR=\temp
REM *****
REM ***** Set the environment variables for the DEStination Drive and Directory
Set CZE-DESDRV=W:
Set CZE-DESDIR=\VIPUSER8.7\spool\ps
REM *****
REM ***** Set the environment variables for root WoRKing Drive and Directory
Set CZE-WRKDRV=C:
Set CZE-WRKDIR=\"Program Files"\CZExtractor
REM *****
REM ***** append the directory path for WinRAR program into current path
path %path%;C:\Program Files\WinRAR
REM *****
REM ***** Change to the working Drive and Directory
%CZE-WRKDRV%
CD %CZE-WRKDIR%
REM *****
REM ***** check to see if DEStination directory is present, if not, then create it.
IF NOT EXIST %CZE-DESDRV%%CZE-DESDIR%\ MKDIR %CZE-DESDRV%%CZE-DESDIR%\
REM *****
REM ***** check to see if ARChive directory is present, if not, then create it.
IF NOT EXIST %CZE-ARCDRV%%CZE-ARCDIR%\ MKDIR %CZE-ARCDRV%%CZE-ARCDIR%\
REM *****
IF EXIST %CZE-WRKDRV%%CZE-WRKDIR%\files-in.txt REN %CZE-WRKDRV%%CZE-WRKDIR%\files-in.txt files-inlast.txt
REM *****
REM ***** create a file containing directory listing of the source directory
dir %CZE-SRCDRV%%CZE-SRCDIR%\*.gz /O:D /T:W > %CZE-WRKDRV%%CZE-WRKDIR%\files-in.txt
REM *****
REM ***** display the files that will be processed to the screen
ECHO **************************************************************************
ECHO The following files have been discovered and will be processed
ECHO **************************************************************************
%CZE-WRKDRV%%CZE-WRKDIR%\files-in.txt
ECHO **************************************************************************
ECHO **************************************************************************
REM *****
REM ***** Using WinRAR decompress all gz files within the SoURce directory
winRAR e -y %CZE-SRCDRV%%CZE-SRCDIR%\*.gz %CZE-DESDRV%%CZE-DESDIR%
REM *****
REM ***** create a file containing directory listing of the DEStination directory
dir %CZE-DESDRV%%CZE-DESDIR%\*.ps /O:D /T:W > %CZE-WRKDRV%%CZE-WRKDIR%\files-out.txt
ECHO **************************************************************
ECHO The following uncompressed files have been created
ECHO **************************************************************
REM %CZE-WRKDRV%%CZE-WRKDIR%\files-out.txt
REM *****
REM ***** DELETE all indx files within the DEStination directory
IF EXIST %CZE-DESDRV%%CZE-DESDIR%\*.indx DEL /Q %CZE-DESDRV%%CZE-DESDIR%\*.indx
REM *****
REM ***** Move all files from the SouRCe directory to the ARChive directory
IF EXIST %CZE-SRCDRV%%CZE-SRCDIR%\*.* MOVE %CZE-SRCDRV%%CZE-SRCDIR%\*.* %CZE-ARCDRV%%CZE-ARCDIR%\
REM *****
:End_Procedure
REM *****
REM ***** restore the original window colors
Color
REM EXIT


OK sorry, I think that just came across dumb. Absolutely no need to post all that.

After studying the winrar commands and switches and trying SEVERAL things, I came up with the following:

Winrar has a switch that would do what I need.

switch
-to
Process files older than the specified time period.

where I could enter 1h.

That should process files older than one hour. Simple. And in testing it works fine with .rar files. But it has no effect on tar.gz files. unfortunately I need to make this work with tar.gz files.Is there another solution or is there another utility I should be using? This is on a Server 08 platform...Quote

WinRAR
From Wikipedia, the free encyclopedia

WinRAR 3.93 in Windows 7
Developer(s) Eugene Roshal, Alexander Roshal
Initial release 1995
Stable release 4.00 (March 7, 2011; 1 day ago (2011-03-07)[1]) [+/−]
Preview release [+/−]
Development status Current
Written in C++
Operating system Windows 95, 98, Me, 2000, XP, VISTA, 7, Mac OS X, FreeBSD, Linux (Wine required for GUI), OS/2[2]
Available in Multilingual (46+ languages)
Type File archiver
License Commercial, Proprietary, Shareware
Website Primary: www.rarlab.com
Secondary: www.win-rar.com

WinRAR is a shareware file archiver and data compression utility developed by Eugene Roshal, and first released in autumn of 1993.[3] It is one of the few applications that is able to create RAR archives natively, because the encoding method is held to be proprietary.
If the shoe fits...


Discussion

No Comment Found