Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2005
    Posts
    13

    Unanswered: DOS or Batch Commands for Windows

    Hi,

    I am trying to automate a job which i require to do everyday. However, i encounter some problems. Hence, i would appreciate all fellow experts to shed some light.

    Here i go.

    Steps

    1) Unzip a file
    2) Search the contents of the file and extract the useful information and
    dump them in a file.

    Here are my codes.

    if exist F:\home\weekly\Reports goto process
    echo "No Mapped Drive Found"
    echo "Please consult Administrator"
    rocess
    mkdir "c:\batch_test\reports"
    F:
    CD F:\home\weekly\Reports
    find /c "101010102010491" view.txt

    ..continue........


    Please do advice.

    Thank you so much.

    Regards.

  2. #2
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    248
    Hi, I presume you're familiar with shell scripting. I (want to) know very little of batch files, but for me the stuff written here http://www.die.net/doc/linux/abs-guide/dosbatch.html would be helpful...
    Another way of doing some clever assembly in Windows is to use PERL, what can be obtained here: http://aspn.activestate.com/ASPN.

    Regards

  3. #3
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool


    Or, just complete your script:
    Code:
    if exist F:\home\weekly\Reports goto process
      echo "No Mapped Drive Found"
      echo "Please consult Administrator"
      exit 1
    
    :process
    if NOT exist c:\batch_test\reports mkdir "c:\batch_test\reports"
    
    F:
    CD F:\home\weekly\Reports
    
    REM To uncompress a file, you need the WinZip Command Line Support Add-On
    REM I don't know the actual program name, but let's say it's: winzbat.exe
    REM ...Uncompress file:
    
    winzbat.exe -u view.txt.zip
    
    REM ...Search for string and put results in other file:
    
    find /c "101010102010491" view.txt >view_find_results.log



    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  4. #4
    Join Date
    Jan 2005
    Posts
    13

    Smile

    Quote Originally Posted by LKBrwn_DBA

    Or, just complete your script:
    Code:
    if exist F:\home\weekly\Reports goto process
      echo "No Mapped Drive Found"
      echo "Please consult Administrator"
      exit 1
    
    :process
    if NOT exist c:\batch_test\reports mkdir "c:\batch_test\reports"
    
    F:
    CD F:\home\weekly\Reports
    
    REM To uncompress a file, you need the WinZip Command Line Support Add-On
    REM I don't know the actual program name, but let's say it's: winzbat.exe
    REM ...Uncompress file:
    
    winzbat.exe -u view.txt.zip
    
    REM ...Search for string and put results in other file:
    
    find /c "101010102010491" view.txt >view_find_results.log



    Hi LKBrwn_DBA,

    Thank you so much. Deeply appreciate it.

  5. #5
    Join Date
    Jan 2005
    Posts
    13
    Hi,

    How do i make 2 sequential search using the find command?

    find /c "101010102010491" "101010102010499" view.txt > view_find_results.log

    Please advice.

    Thank you.

  6. #6
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by process
    Hi,

    How do i make 2 sequential search using the find command?

    find /c "101010102010491" "101010102010499" view.txt > view_find_results.log
    Code:
    find /c "101010102010491" view.txt > view_find_results.log
    find /c "101010102010499" view.txt >> view_find_results.log
    For more elaborate stuff, I suggest using the Windows ports of GNU utilities, such as grep, awk, sed, and many others (look at gnuwin32.sourceforge.net).

    You can also use the jar utility (freely available from java.sun.com) to work with .ZIP archives.

  7. #7
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    248
    Would something like:
    Code:
    find /c "101010102010491" view.txt > view_find_results.log
    find /c "101010102010499" view.txt >> view_find_results.log
    be fitting for your needs? And don't mind for the possible redundant lines in your logfile.
    Seems to me you'd still be better off with a scripting language like PERL since with that you can do it all in once with a regular expression (and much, much more)...

    Regards
    Last edited by Tyveleyn; 09-01-06 at 11:27.

  8. #8
    Join Date
    Jan 2005
    Posts
    13
    Hi,

    Besides the sequential search (find command), can i do a concurrent one using the find command?

    Thanks.

Posting Permissions

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