none
how to concatenate strings with the lines of a text file RRS feed

  • Question

  • Hello 
    I've been trying to concatenate strings with the lines of a text file, but something is wrong with my code and I belive is the agruments I am using in the the For cycle. If any one can help me I'll much appreciate it. 
    My code is:
    [code]@echo off
    set "input=C:\Users\123\Desktop\List.txt"
    for /f "usebackq tokens=*" %%F in ("%input%") do (
            set "str1=C:\some directory\"
    set "str2=%%~F"
    set "str3=.pdf"
    set "str4=%str1%%str2%%str3%"
    echo.%str4%
    )[/code]
    and the text file is something like:
    [code]121122
    122233
    123344
    124455[/code]
    But I am only getting a wrong answer and I have to run it like 3 times to get a real result and it's wrong, the first two are blank spaces and the third one gives back the last line in the text file but repeated n times where, n is the number of lines in the text file. 
    Result: 
    [code]C:\Users\123\Desktop>concatenate.bat
    C:\Users\123\Desktop>concatenate.bat
    C:\Users\123\Desktop>concatenate.bat
    C:\some directory\124455.pdf
    C:\some directory\124455.pdf
    C:\some directory\124455.pdf
    C:\some directory\124455.pdf
    C:\some directory\124455.pdf
    C:\Users\123\Desktop>[/code]
    So, if any one has a clue on what is wrong please let me know. 
    Regards
    -Victor-
    Tuesday, September 18, 2012 12:28 AM

All replies