Home > Software engineering >  VB Script batch read TXT file
VB Script batch read TXT file

Time:10-08

There are 100 TXT file such as a folder
Read all the TXT file search a column of figures, the search for the column of figures in TXT file is copied to a local folder

CodePudding user response:

You can use the FSO object implementation, search there

CodePudding user response:


C: \ & gt; findstr searches/?
Looking for strings in files.

FINDSTR searches [/B] [/B] [/M] [/R]/[S] [/I] [/X] [/V] [/N] [/M] [/O] [/F: file]
[/C: string] [/G: file] [/D: dir list] [/A: color attributes] [/OFF [the LINE]]
Strings [[drive:] [path] filename [...]]

/B at the beginning of a line matching pattern,
/E at the end of a line matching pattern,
/L by keyword using a search string,
/R will search string used as a general expression,
/S in the current directory search matching files and subdirectories in a directory,
/I specify search case insensitive,
Print completely matching line/X,
Print does not include the matching line/V only,
/N every before printing of the matching rows,
/M if the file contains a match, only print the filename,
/O in each match before character offset printing,
/P ignore file with the nonprintable characters,
/OFF [the LINE] don't skip with offline file attributes,
/A: attr hexadecimal digits are destined to color attribute, please see the "color/?"
/F: file read file list from the specified file (/on behalf of the console),
/C: string using the specified string as a text search string,
/G: file get search string from the specified file, (/on behalf of the console),
/D: dir find a semicolon as separators directory list
Strings to find words,
[drive:] [path] filename
To find the specified file,

Prefix unless parameters have a/C, please use the space separated by a search string,
For example: 'FINDSTR searches "hello there" x.y' seeking "hello" or in file x.y
"There," 'FINDSTR searches/C: "hello there" x.y' file x.y looking for
"Hello there,"

The general expression of quick reference:
Wildcard: any characters
* repeat: characters or number of categories of zero or more than zero before
^ line location: the beginning of a line of
$row position: the end
Categories: [class] characters in any character set characters
[^ class] fill character categories: any character not in the character set
Scope: x-y in any character within the specified range
\ x Escape: metacharacters word usage of x
\ & lt; Xyz position: words start
Xyz \ & gt; Location: the end of the word is

About the FINDSTR searches the common expression of the details, please see online command reference,

C: \ & gt;
  •  Tags:  
  • VBA
  • Related