Computing.Net > Forums > Programming > Modification to the current script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Modification to the current script

Reply to Message Icon

Name: ksuchetan
Date: October 21, 2008 at 10:31:23 Pacific
OS: Windows XP
CPU/Ram: 2gb
Comment:

Hi,

I have to modify the below mentioned script to generate a %3_COMBINED.TXT rather than COMBINED.TXT

The script is as follows.

@ECHO OFF
set str=
CD%1
TYPE NUL>"%2_COMBINED.TXT"
type nul>COMBINED.TXT

for /f "delims=" %%t in ('dir/b/a-d *%2*') do (
for /f "usebackq delims=" %%a in ("%%t") do (
call :output "%%a"
)
)
for /f "delims=" %%a in (COMBINED.TXT) do (
echo %%a>>%2_COMBINED.TXT
)
goto :eof
:output
set str=%*
set str=%str:|=^|%
if not %str%==" " echo:%str:~1,-1%>>COMBINED.TXT
goto :eof


I tried to modify the script as follows



@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
set str=
CD%1
TYPE NUL>"%2_COMBINED.TXT"
type nul>"%3_COMBINED.TXT"

for /f "delims=" %%t in ('dir/b/a-d *%2*') do (
for /f "usebackq delims=" %%a in ("%%t") do (
call :output "%%a"
)
)
for /f "delims=" %%a in (%3_COMBINED.TXT) do (
echo %%a>>%2_COMBINED.TXT
)
goto :eof
:output
set str=%*
set str=%str:|=^|%
if not %str%==" " echo:%str:~1,-1%>>%3_COMBINED.TXT
goto :eof

I get three output files


%2_COMBINED.TXT
%3_COMBINED.TXT
BOTH OF ZERO BYTES

and _COMBINED.TXT

The _COMBINED.TXT HAS THE CORRECT VALUES.

There is something I am missing Please guide.

Thanks In Advance

Thanks In Advance



Sponsored Link
Ads by Google

Response Number 1
Name: ksuchetan
Date: October 22, 2008 at 11:30:47 Pacific
Reply:

Thanks alot guys for all your help in past my
issue is resolved

I tried to assign the run time value to a variable and it did all the trick.

@ECHO OFF
set str=
CD%1

TYPE NUL>"%3_COMBINED.TXT"
type nul>"%2_COMBINED.TXT"
SET cOMBO=%2_COMBINED.TXT

for /f "delims=" %%t in ('dir/b/a-d *%3*') do (
for /f "usebackq delims=" %%a in ("%%t") do (
call :output "%%a"
)
)
for /f "delims=" %%a in (%COMBO%) do (
echo %%a>>%3_COMBINED.TXT
)
goto :eof
:output
set str=%*
set str=%str:|=^|%
if not %str%==" " echo:%str:~1,-1%>> "%COMBO%"
goto :eof


Thanks In Advance

Thanks In Advance


0
Reply to Message Icon

Related Posts

See More


awk help Need batch file help



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Modification to the current script

batch script to copy current date f www.computing.net/answers/programming/batch-script-to-copy-current-date-f/14097.html

Read file concatenated to the EXE www.computing.net/answers/programming/read-file-concatenated-to-the-exe/14415.html

Assign file contents to batch var! www.computing.net/answers/programming/assign-file-contents-to-batch-var/15181.html