Using batch script to writedelete symbols into a text file

Home Forums Scripting General Scripting Using batch script to writedelete symbols into a text file

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    igor7
    Member
    #156506

    Hi!!
    Following this thread, I need to perform something similar.
    We have an *.txt file which contain users Information (first and last name, pager number, company name etc). This file reside on some network share and it used by some message system. This system sending messages/alerts to users from this txt file according to their work time (shifts). Bellow some quote of this file:

    [COLOR=#555a5f][FONT=Verdana]### Shift 1[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]#[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]#Edward Black:8324:All:Shift 1[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]#Melanie Colins:3165:All:shift 1[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]#Paul Johns:3159:All:shift 1[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]#Igor Gorin:8261:All:Shift 1[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]#Nebo McLain:3171:Novelus:shift 1[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]#Andrew Smeet:3350:Novelus:shift 1[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]#Alex Katz:3182:DHL:shift 1[/COLOR][/FONT]
    [/CODE]

    [COLOR=#555a5f][FONT=Verdana]Sign # before each line says to the system do not send messages to this user and vice versa, when line with user information doesn’t contain # sign, user will receive all messages.[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]Currently each user needs to edit this file twice at day, at beginning of the shift (enable messages) and at end of the shift (disable messages).[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]I’m looking for script which will use input method, something like this:[/FONT][/COLOR]
    [CODE]
    [COLOR=#555a5f][FONT=Verdana]@echo off[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]echo.[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]echo Please insert your input here:[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]echo.[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]:input[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]set INPUT= [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]set /P INPUT=Type input: %=%[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]if “%INPUT%”==”” goto input[/COLOR][/FONT]
    [/CODE]
    [COLOR=#555a5f][FONT=Verdana]and according to the input script will check each line in this file for # sign existence. I.e. if # line exist, it remove it, it not exist it will add #sign to beginning of the line.[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]For example, for single user I’ll use his first and/or last name (or pager number) as input.[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]If I need all shift 1 users, I’ll use shift1 as input, or if I need Novellus users, I’ll use Novellus as input. So in this way whenever I’ll run this script it will add/remove # sign automatically, i.e. if user currently receives messages, he will not receive them anymore, and if he doesn’t receive messages, he will start to receive. Any help is much [COLOR=#555a5f][FONT=Verdana]appreciated[/FONT][/COLOR]![/FONT][/COLOR][CODE]
    ### Shift 1
    #
    #Edward Black:8324:All:Shift 1
    #Melanie Colins:3165:All:shift 1
    #Paul Johns:3159:All:shift 1
    #Igor Gorin:8261:All:Shift 1
    #Nebo McLain:3171:Novelus:shift 1
    #Andrew Smeet:3350:Novelus:shift 1
    #Alex Katz:3182:DHL:shift 1
    [/CODE]

    Sign # before each line says to the system do not send messages to this user and vice versa, when line with user information doesn’t contain # sign, user will receive all messages.
    Currently each user needs to edit this file twice at day, at beginning of the shift (enable messages) and at end of the shift (disable messages).
    I’m looking for script which will use input method, something like this:

    [COLOR=#555a5f][FONT=Verdana]@echo off[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]echo.[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]echo Please insert your input here:[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]echo.[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]:input[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]set INPUT= [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]set /P INPUT=Type input: %=%[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]if “%INPUT%”==”” goto input[/COLOR][/FONT]
    [/CODE]
    [COLOR=#555a5f][FONT=Verdana]and according to the input script will check each line in this file for # sign existence. I.e. if # line exist, it remove it, it not exist it will add #sign to beginning of the line.[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]For example, for single user I’ll use his first and/or last name (or pager number) as input.[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]If I need all shift 1 users, I’ll use shift1 as input, or if I need Novellus users, I’ll use Novellus as input. So in this way whenever I’ll run this script it will add/remove # sign automatically, i.e. if user currently receives messages, he will not receive them anymore, and if he doesn’t receive messages, he will start to receive. Any help is much [COLOR=#555a5f][FONT=Verdana]appreciated[/FONT][/COLOR]![/FONT][/COLOR][CODE]
    @echo off
    echo.
    echo Please insert your input here:
    echo.
    :input
    set INPUT=
    set /P INPUT=Type input: %=%
    if “%INPUT%”==”” goto input
    [/CODE]
    and according to the input script will check each line in this file for # sign existence. I.e. if # line exist, it remove it, it not exist it will add #sign to beginning of the line.
    For example, for single user I’ll use his first and/or last name (or pager number) as input.
    If I need all shift 1 users, I’ll use shift1 as input, or if I need Novellus users, I’ll use Novellus as input. So in this way whenever I’ll run this script it will add/remove # sign automatically, i.e. if user currently receives messages, he will not receive them anymore, and if he doesn’t receive messages, he will start to receive. Any help is much appreciated!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.