Results 1 to 3 of 3

Thread: Help on DOS batch script

  1. #1

    Help on DOS batch script

    Hello Friends,

    I have a script in which i have 4(variable) directories and iam assigning them as D_1, D_2 etc. I have to generate another bat file with some set of codes which are common but only the folder names needs to be changed. script is as follows
    set DIR=4
    set D_1=make
    set D_2=lib
    set D_3=navdata
    set D_4=STLPORT

    del temp1.txt output.txt
    FOR /L %%G IN (1,1,%DIR%) do (
    SET /A number=1
    SET NUM=%number%
    SET NUM=%number%
    SET TOGETHER=D_%NUM%
    ECHO %%TOGETHER%%

    echo value of n is %n%
    copy temp.txt temp1.txt

    change.com temp1.txt "RGK" "%%"
    change.com temp1.txt "DIRECT" ">>"


    rem change.com temp1.txt "folder" "%CUR%"

    for /f "tokens=* delims= " %%a in (temp1.txt) do (
    echo %%a >>output.txt

    )
    SET /A number=%number%+1

    )
    here temp1 has the contents
    mkdir folder
    cd folder
    %SSafe% workfold $/dev %CD%
    %SSafe% Get $/dev/folder -W -R -I-Y -GTM >>%logfile%
    cd..
    MY ISSUE IS THAT I WANT TO CHANGE THIS folder TO THE D_1, D_2 SO PLEASE SUGGEST ME HOW TO GO FURTHER.

  2. #2
    XP + akbarri's Avatar
    Join Date
    Dec 2008
    Location
    Caterpillar Inc
    Posts
    938
    Blog Entries
    3
    i did run & analize ur batch script but still confuse with what u hope for! (issue)
    can u explain ur program structure or just detail output of batch file that u hope for beside ur example DOS batch script.
    ex detail output:
    - i want to make a directory(ex name:"folder") and 4 sub-dir of "folder"
    - 4 sub-dir of "folder" will be rename as "make", "lib", "navdata" and "stlport"
    .........

  3. #3
    Junior Member
    Join Date
    Jun 2009
    Posts
    2

    Processing a list of folders in a script

    I was also confused as to what you are trying to accomplish.

    MY ISSUE IS THAT I WANT TO CHANGE THIS folder TO THE D_1, D_2 SO PLEASE SUGGEST ME HOW TO GO FURTHER.
    I assume you want to do something (the same thing) in each of the folders in a list. I will show how to pass a list of folders to a script and do the same thing (list files in the folder as an example) in each folder.



    Code:
    # Script sample.txt
    # Folder list comes in as input argument - list. Each folder is separated by
    # | (pipe), folder names themselves can't have | in their names.
    var str list
    
    var str folder
    # Set folder till the next pipe.
    if ( { sen "^|^" $list } > 0 )
        stex "^|^]" $list > $folder
    else
        set $folder = $list
    endif
    
    while ($folder <> "")
    do
        sal "^|^" "" $folder > null
    
        # Do something with folder. We will list files as example.
        lf -n "*" $folder >> output.txt
    
        if ( { sen "^|^" $list } > 0 )
            stex "^|^]" $list > $folder
        else
            set $folder = $list
        endif
    done


    Save the script in C:\Scripts\sample.txt. Call it as

    Code:
    script sample.txt list("folder1|folder2|...")

    You can also set the list of folders at the top of the script ( set $list="folder1|folder2|..." ) as you did in your script. Script is in biterscripting ( http://www.biterscripting.com ) . You can translate it to DOS batch if it meets your requirements.

    Patrick

Similar Threads

  1. Simple dos Batch Script
    By stdj in forum Programming Forum
    Replies: 0
    Last Post: 04-24-08, 08:56 PM
  2. Using PSEXEC and VBS script with WSUS
    By scj6771 in forum Software Forum
    Replies: 2
    Last Post: 11-14-07, 03:52 PM
  3. Need DOS Batch Functions Help
    By LuFu68 in forum Software Forum
    Replies: 4
    Last Post: 04-05-07, 06:01 PM
  4. Please new to dsl and already having problem
    By weedancer in forum General Broadband Forum
    Replies: 46
    Last Post: 03-09-07, 06:23 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •