V
V
vibe-vibe2015-08-03 21:10:03
Windows
vibe-vibe, 2015-08-03 21:10:03

How to display certain words according to a given rule from a .txt document?

There is a folder with .txt documents. Each document has a line like this:
Mass x
where x is a number, and this number is different in each document. We need a program that will process all text files in a folder and display the result in the form:
Bolt mass 100
Nut mass 50
Bolt, nut are the names of text documents that need to be displayed. Next comes the weight value, which was displayed in the corresponding document.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2015-08-03
@vibe-vibe

www.powergrep.com is a universal soldier
, however, I tried a couple of times to link with file names, and I didn’t find how to do it
because - first combine all the files into one, here are the ways: www.fullstuffing.com/2011/01/ txt.html
(I recommend TXTcollector, it will write the names of the source files in the result),
and then extract the data with a grep

E
Eugene, 2015-08-04
@yellowmew

briefly in PowerShell

Get-Childitem путь_к_папке_с_файлами | foreach {$mass = (Get-Content $_.FullName) -match "масса *" ; write-host $_.Name$mass}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question