On Mar 7, 9:41=A0am, tcdrake <rymi...@[EMAIL PROTECTED]
> wrote:
> On Mar 7, 9:25=A0am, tcdrake <rymi...@[EMAIL PROTECTED]
> wrote:
>
>
>
>
>
> > On Mar 7, 8:01=A0am, tcdrake <rymi...@[EMAIL PROTECTED]
> wrote:
>
> > > On Mar 6, 3:47=A0pm, Ted Davis <tda...@[EMAIL PROTECTED]
> wrote:
>
> > > > On Thu, 06 Mar 2008 12:44:23 -0800, tcdrake wrote:
> > > > > On Mar 6, 1:25=A0pm, tcdrake <rymi...@[EMAIL PROTECTED]
> wrote:
> > > > >> We recieve zip files in the following format...yyyymmdd-#.zip
whe=
re #
> > > > >> starts at 1 and increments up to 79. I need to unzip these
files =
into
> > > > >> seperate folders based on a specified folder name. Here is what
I=
> > > > >> have....
>
> > > > >> BEGIN{
> > > > >> timetab(z,time() - 86400)
>
> > > > >> printf("c:\\progra~1\\winzip\\wzunzip.exe -e -s %s%02s%02s-.zip
c=
:\
> > > > >> \test\\1\n",z["YEAR"],z["MONTH"],z["DAY"]) =A0> "test.bat"
> > > > >> printf("c:\\progra~1\\winzip\\wzunzip.exe -e -s %s%02s%02s-.zip
c=
:\
> > > > >> \test\\2\n",z["YEAR"],z["MONTH"],z["DAY"]) =A0> "test.bat"
>
> > > > >> }
> > > > >> As you can see I have the date portion down its the # after the
d=
ash in
> > > > >> the zip name I don't know how to do. I'm pretty sure I need the
+=
+ but
> > > > >> not sure how.
>
> > > > >> thanks.
>
> > > > > I think I need to add more info....
>
> > > > > We have 80 zip files coming into one FTP directory each day
labled=
> > > > > yyyymmdd-(store number).zip. These will then need to be
extracted =
to the
> > > > > folder associated to each location. The location folder name is
ra=
ndom and
> > > > > does not match the store number in the zip name. So from what I
ga=
ther one
> > > > > way would be to scan the FTP incoming directory to get the ZIP
nam=
es, not
> > > > > sure how to do this in awk. I also need to figure out how to
match=
the zip
> > > > > to the correct folder it needs to be extracted to. Any ideas?
>
> > > > XP batch plus gawk is my strong suite. =A0That code is broken from
t=
he batch
> > > > point of view. =A0In any case, I think a different approach is
neede=
d, one
> > > > based on gawk specific functions. =A0I would start with a batch
wrap=
per
>
> > > > =A0 @[EMAIL PROTECTED]
off
> > > > =A0 dir /b ftp_directory | awk -fscript > }{.bat
>
> > > > I can only do part of the script without knowing how to map the
loca=
tion
> > > > number to the target directory (I'll do this in fully expanded
synta=
x for
> > > > clarity)
>
> > > > =A0 BEGIN{
> > > > =A0 =A0 =A0 =A0 UnZip Command1 =3D
"c:\\progra~1\\winzip\\wzunzip.ex=
e -e -s "
> > > > =A0 =A0 =A0 =A0 UnZip Command2 =3D
> > > > =A0 }
>
> > > > =A0 {
> > > > =A0 =A0 =A0 =A0 match( $0, /([0-9]+)-([0-9]+)\.zip, Array)
> > > > =A0 =A0 =A0 =A0 FileNameDate =3D Array[ 1 ]
> > > > =A0 =A0 =A0 =A0 Location =3D Array[ 2 ]
> > > > =A0 }
> > > > .....
>
> > > > Actually, it's easier to do a a pure batch file.
>
> > > > =A0 for /f "tokens=3D1,2,3 delims=3D.-" %%A in ('dir /b *.zip') do
> > > > "c:\program files\winzip\wzunzip.exe" -e -s %%A%-%B.%%C
c:\test\%%B\=
>
> > > > All one line. =A0Not tested (I'm running out of time and don't
have =
WinZip
> > > > anyway).
>
> > > > --
> > > > T.E.D. (tda...@[EMAIL PROTECTED]
)- Hide quoted text -
>
> > > > - Show quoted text -
>
> > > Thanks T.E.D. I'll have to spend some time checking this out but
will
> > > update if/when I run into trouble.- Hide quoted text -
>
> > > - Show quoted text -
>
> > Here is where I am at....
>
> > I tried the batch file. Unfortunitly with what you had the zip name
> > ended up have the letters EB in it. Here is the output I recieved.
>
> > C:\tawk>"c:\program files\winzip\wzunzip.exe" -e -s 20080305EB.
c:\test
> > \zip\
> > WinZip(R) Command Line Support Add-On Version 1.1 SR-1 (Build 6224)
> > Copyright (c) WinZip Computing, Inc. 1991-2004 - All Rights Reserved
>
> > Password?
>
> > ERROR: Zip file 20080305EB. does not exist
> > Program is terminating!
>
> > The zip file name was 20080305-30.zip. I changed the batch and deleted
> > the %B reference. This caused the zip to be unzipped to the root of
> > test folder.
>
> > Let me try to give me info on what I am trying to do.
>
> > I get 80 zips each day. So today the zips will be named
> > 20080306-1.zip, 20080306-2.zip, 20080306-3.zip, etc..
> > The number after the dash is the location number. I need to unzip each
> > location to a folder based on different location numbers. So location
> > 1 based on the zip name goes to location 090909. Location 2 based on
> > the zip name goes to location 034850987. I have an excel file which
> > assigns locations to each other. Does that help? I hope so as I could
> > really use the help on this.- Hide quoted text -
>
> > - Show quoted text -
>
> Below is the closest I have gotten so far but I still could use some
> help.
>
> for /f "tokens=3D1,2,3 delims=3D-" %%A in ('dir /b *.zip') do
"c:\program
> files\winzip\wzunzip.exe" -e -s %%A%-%.%%C c:\test\%B\
>
> The output looks like this...
>
> C:\tawk>for /F "tokens=3D1,2,3 delims=3D-" %A in ('dir /b *.zip') do "c:
> \program files\winzip\wzunzip.ex
> e" -e -s %A.%C c:\test\B\
>
> C:\tawk>"c:\program files\winzip\wzunzip.exe" -e -s 20080305E.zip. c:
> \test\B\
>
> So what I need to figure out is why the E is showing up in the zip
> name instead of the -(location number). Also why the directory B is
> being reference instead of the location number.- Hide quoted text -
>
> - Show quoted text -
One thing I relized was I didn't have the zip file in the directory I
was running the batch file from...oops. Now with that said it still
doesn't work. Here is what I get....
C:\test>for /F "tokens=3D1,2,3 delims=3D-" %A in ('dir /b *.zip') do "c:
\program files\winzip\wzunzip.ex
e" -e -s %A.%C c:\test\B\
C:\test>"c:\program files\winzip\wzunzip.exe" -e -s 20080123. c:\test\B
\
So the zip file doesn't have the -(location).zip only yyyymmdd.
Also the folder created under test, folder B, shouldn't be B it should
be the location number.
Thanks.


|