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: rename base...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 10 Topic 2205 of 2236
Post > Topic >>

Re: rename based on file name

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

On Fri, 28 Mar 2008 10:08:26 -0700, tcdrake wrote:

>
>> Yes, I do agree that I have a mess on my hands. Doing the best I can
>> with the limited knowledge I have. With that said I don't believe I am
>> renaming the files twice. I unzip only certain files from the ZIP and
>> put them in the correct directory. From there I rename them from
emp.dbf
>> to em080325.dbf.
>>
>> printf("REN c:\\po\test\users\test\\%s\\emp.dbf em%s%02s%02s.dbf\n",
>> $2,substr(y["YEAR"],3,2),y["MONTH"],y["DAY"])>"C:\\test\\doit.bat"
>>
>> I then zip and move to another directory. All that works right now.
>>
>> I took a look at your script T.E.D and please correct me if I
>> missunderstood what you have. It looks like your code seems to rename
>> the dbf to yesterdays date. I also undertand you as saying that small
>> bit of code makes my mess of a code no longer needed. Which part is no
>> longer needed? I ask because your not unzipping/zipping. Is your code
>> supposed to fit into a portion of the awk or batch code I already have?

It inserts yesterday's date between the existing basen name and the
estension.

Yes - it's a fragment to be used where needed. I don't like to do complete
batch files here.

> 
> Well started over and simplified the code with everyone's assistance. I
> set it to unzip to a working directory, rename files, zip and move to
> the correct directory based on the location code. Then process the next
> zip. Here is it for everyone to see.
> 
> BEGIN{
> 
> while ( (getline < "stores.txt")  > 0) { FILENOZIP =
> substr($0,1,(length($0) - 4)) FILEDATE = substr($0,1,8) FILEDATESHRTYR =
> substr($0,3,6)
> STORENUM = substr(FILENOZIP,10,4)
>      while ( (getline < "\\test\\process.txt")  > 0) {
>           if (STORENUM == $1)
>           {
>                DIRECTORY = $2
>           }
>           }
> close("\\test\\stores.txt")
> 
> 
> 
> printf("Processing Store Number %s Date %s Direcotry %s
> \n",STORENUM,FILEDATE,DIRECTORY)
> printf("DEL workingtemp\\*.*\n") > "test.bat" printf("WINZIP
> c:\\progra~1\\winzip\\wzunzip.exe -e %s.zip @[EMAIL PROTECTED]
> workingtemp\n",FILENOZIP) > "test.bat"
> 
> 
> 
> printf("RENAME workingtemp\\tnd.DBF workingtemp\\TD%s.dbf
> \n",FILEDATESHRTYR) > "test.bat"
> printf("RENAME workingtemp\\ite.DBF workingtemp\\IT%s.dbf
> \n",FILEDATESHRTYR) > "test.bat"
> printf("RENAME workingtemp\\Gsle.DBF workingtemp\\GS%s.dbf
> \n",FILEDATESHRTYR) > "test.bat"
> 
> printf("wzzip.exe -m C:\\iFtpSvc\\info\\users\\download\\test\\%s\\
> %s.zip\n",DIRECTORY,FILEDATE) > "test.bat"
> 
> 
> 
> 
> }

It's *much* simpler to leave the file names to the command processor and
use awk for the thing it does well - dealing with paths with backslashes
is not one of them (in part because of the ease of missing doubling one
that needs it and accidentally doubling one that doesn't).

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




 10 Posts in Topic:
rename based on file name
tcdrake <rymills@[EMAI  2008-03-26 05:16:13 
Re: rename based on file name
Cesar Rabak <csrabak@[  2008-03-26 11:26:44 
Re: rename based on file name
Ed Morton <morton@[EMA  2008-03-26 10:04:06 
Re: rename based on file name
Ted Davis <tdavis@[EMA  2008-03-26 11:35:42 
Re: rename based on file name
Cesar Rabak <csrabak@[  2008-03-26 18:18:11 
Re: rename based on file name
Ted Davis <tdavis@[EMA  2008-03-26 19:10:01 
Re: rename based on file name
tcdrake <rymills@[EMAI  2008-03-28 08:30:29 
Re: rename based on file name
tcdrake <rymills@[EMAI  2008-03-28 10:08:26 
Re: rename based on file name
Ted Davis <tdavis@[EMA  2008-03-28 15:17:02 
Re: rename based on file name
Cesar Rabak <csrabak@[  2008-03-28 20:40:45 

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 23:18:26 CDT 2008.