Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: incrementin...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 16 Topic 2179 of 2236
Post > Topic >>

Re: incrementing numbers

by tcdrake <rymills@[EMAIL PROTECTED] > Mar 7, 2008 at 07:41 AM

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
where=
 #
> > > >> starts at 1 and increments up to 79. I need to unzip these files
in=
to
> > > >> 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
das=
h 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
rand=
om and
> > > > does not match the store number in the zip name. So from what I
gath=
er one
> > > > way would be to scan the FTP incoming directory to get the ZIP
names=
, not
> > > > sure how to do this in awk. I also need to figure out how to match
t=
he 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
the=
 batch
> > > point of view. =A0In any case, I think a different approach is
needed,=
 one
> > > based on gawk specific functions. =A0I would start with a batch
wrappe=
r
>
> > > =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
locati=
on
> > > number to the target directory (I'll do this in fully expanded
syntax =
for
> > > clarity)
>
> > > =A0 BEGIN{
> > > =A0 =A0 =A0 =A0 UnZip Command1 =3D
"c:\\progra~1\\winzip\\wzunzip.exe =
-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
Wi=
nZip
> > > 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.




 16 Posts in Topic:
incrementing numbers
tcdrake <rymills@[EMAI  2008-03-06 11:25:29 
Re: incrementing numbers
tcdrake <rymills@[EMAI  2008-03-06 12:44:23 
Re: incrementing numbers
Ted Davis <tdavis@[EMA  2008-03-06 15:47:19 
Re: incrementing numbers
tcdrake <rymills@[EMAI  2008-03-07 06:01:26 
Re: incrementing numbers
tcdrake <rymills@[EMAI  2008-03-07 07:25:05 
Re: incrementing numbers
tcdrake <rymills@[EMAI  2008-03-07 07:32:06 
Re: incrementing numbers
Ted Davis <tdavis@[EMA  2008-03-07 15:04:41 
Re: incrementing numbers
Ted Davis <tdavis@[EMA  2008-03-07 19:58:45 
Re: incrementing numbers
tcdrake <rymills@[EMAI  2008-03-07 07:41:51 
Re: incrementing numbers
tcdrake <rymills@[EMAI  2008-03-07 13:06:05 
Re: incrementing numbers
tcdrake <rymills@[EMAI  2008-03-10 07:22:41 
Re: incrementing numbers
tcdrake <rymills@[EMAI  2008-03-12 12:46:29 
Re: incrementing numbers
Ted Davis <tdavis@[EMA  2008-03-12 15:04:55 
Re: incrementing numbers
tcdrake <rymills@[EMAI  2008-03-12 13:23:37 
Re: incrementing numbers
Ted Davis <tdavis@[EMA  2008-03-12 20:03:31 
Re: incrementing numbers
tcdrake <rymills@[EMAI  2008-03-26 06:48:51 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri May 16 9:25:02 CDT 2008.