Overwrite an existing file(s)

June 29, 2009 at 13:45:22
Specs: Windows XP
I have 2 files in a say c:\input\ldap.
File names are

I need to remove some lines from both of these files and save it and copy to c:\output\ldap.

@echo off & setLocal enableDELAYedexpansion

for /f "tokens=* delims= " %%a in ('dir/b *.txt') do (
echo %%a

:count lines; set T & R
for /f "tokens=* delims= " %%d in ('find /v /c "" ^< %%a') do (
set T=%%d
set /a R=!T!-2
-- some code here that would call :noFIRST

::== noFIRST.bat
@echo off > NewLDAP1.txt

echo !Input!
for /f "tokens=* delims= " %%a in ('dir/b *.txt') do (
for /f "tokens=*" %%L in (%%a) do call :1 %%L
goto :eof

if %FIRST%==N echo %*>>NewLDAP1.txt
goto :eof


find /v "" NewLDAP1.txt > ~Temp.txt
for /f "tokens=1,* delims=[]" %%a in (~Temp.txt) do set Last=%%a
type NewLDAP1.txt | find /v "%Last%" >> NewLDAP2.txt

==> don't know how to read the 1st file so again I am dir/b LDAP*.txt.

for /f "tokens=* delims= " %%a in ('dir/b LDAP*.txt') do (
move/y NewLDAP2.txt %%a

del New*.txt
del ~Temp.txt

move *.txt c:\output\ldap.

It does not read the second file at all. What do I need to change in call :chopLast?? Please read above comments.

Ok, so trying to copy NewLDAP2.txt to L1_CC_yyyymmdd.txt and then delete NewLDAP2.txt and move the L1_CC* to /output/ldap.

Then again copy NewLDAP2.txt to L1_DD_yyyymmdd.txt and then delete NewLDAP2.txt and move the L1_DD* to /output/ldap.

Hope this makes sense.

See More: Overwrite an existing file(s)

Report •

June 29, 2009 at 15:55:59
This should be posted in the "Programming" forum. The link is on the right hand side of this page.


Report •
Related Solutions

Ask Question