On Wed, 26 Mar 2008 05:16:13 -0700, tcdrake wrote:
> I think one option is to have a piece of code which goes through the
> directory and makes a list of all the files. Then use that list to
rename
> the unzipped files based on the list. I just not sure how to implement
it.
> Any ideas?
In your example code, you seem to be trying to rename the same files twice
to different names - that doesn't work. Also, you should not use getline
that way - it's so much better to pass the file name as an argument and
let awk take care of the file.
In a batch file:
for %%A in (*.dbf) do (
rename code here
%%~nA is the file's base name without the extesnion
%%~xA is the extension
%%~dA is the drive letter and colon
%%~pA is the directory
)
The only thing you need awk for is to generate the various date strings.
Your approach to generating date strings is *way* too complicated - it's
better to use
batch file
for /f "tokens=1,2" %%A in ('awk "BEGIN{print
strftime(\"%%Y%%m%%d\",systime()-86400) \" \"
strftime(\"%%Y%%m%%d\",systime()-2*86400)}"') do ( set yesterday=%%A& set
daybefore=%%B)
All one line. Then the two dates are in the named environment variables
in YYYYMMDD format. I don't see any reason for the daybefore, you your
code generates it.
So your big mess of way too complicated awk code seems to resolve to
@[EMAIL PROTECTED]
off
set base=c:\po\test\users\test\
for /f "tokens=1,2" %%A in ('awk "BEGIN{print
strftime(\"%%Y%%m%%d\",systime()-86400) \" \"
strftime(\"%%Y%%m%%d\",systime()-2*86400)}"') do ( set yesterday=%%A& set
daybefore=%%B)
for /f %%A in (stores.txt) do (
for %%B in ( %base%%%A\*.dbf) do ren %%B %%~nB%yesterday%%%~xB
)
Using gawk.exe in the Windows XP environment. Remember that real lines
are indented two spaces, lines indented less than that are wrapped from
the above line.
--
T.E.D. (tdavis@[EMAIL PROTECTED]
)


|