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 3 of 16 Topic 2179 of 2236
Post > Topic >>

Re: incrementing numbers

by Ted Davis <tdavis@[EMAIL PROTECTED] > Mar 6, 2008 at 03:47 PM

On Thu, 06 Mar 2008 12:44:23 -0800, tcdrake wrote:

> On Mar 6, 1:25 pm, 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 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"])  > "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"])  > "test.bat"
>>
>>
>> }
>> As you can see I have the date portion down its the # after the dash 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 random
and
> does not match the store number in the zip name. So from what I gather
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 the
zip
> to the correct folder it needs to be extracted to. Any ideas?


XP batch plus gawk is my strong suite.  That code is broken from the batch
point of view.  In any case, I think a different approach is needed, one
based on gawk specific functions.  I would start with a batch wrapper

  @[EMAIL PROTECTED]
 off
  dir /b ftp_directory | awk -fscript > }{.bat

I can only do part of the script without knowing how to map the location
number to the target directory (I'll do this in fully expanded syntax for
clarity)

  BEGIN{
	UnZip Command1 = "c:\\progra~1\\winzip\\wzunzip.exe -e -s "
	UnZip Command2 =
  }

  {
	match( $0, /([0-9]+)-([0-9]+)\.zip, Array)
	FileNameDate = Array[ 1 ]
	Location = Array[ 2 ]
  }
......

Actually, it's easier to do a a pure batch file.

  for /f "tokens=1,2,3 delims=.-" %%A in ('dir /b *.zip') do
"c:\program files\winzip\wzunzip.exe" -e -s %%A%-%B.%%C c:\test\%%B\

All one line.  Not tested (I'm running out of time and don't have WinZip
anyway).

-- 
T.E.D. (tdavis@[EMAIL PROTECTED]
)




 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:27:45 CDT 2008.