Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 527 Vote(s) - 3.48 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Split text file into multiple files using windows batch scripting

#1
I need to split one text file into multiple files using windows batch script, could anybody light me up?

sample text file:

abc1-10
abc1-11
abc1-12
xyz2-01
xyz2-02
xyz3-01
xyz3-02

in this case, it has to split into 3 files, first one consists the lines `abc1-xx`, second one consists `xyz2-xx` and `xyz3-xx` go to the last one
Reply

#2
You could use a batch file, but why not just use [FINDSTR][1] command?

findstr /R "^abc1-" sample.txt > file1.txt
findstr /R "^xyz2-" sample.txt > file2.txt
findstr /R "^xyz3-" sample.txt > file3.txt


[1]:

[To see links please register here]

Reply

#3
This may help - it will split the text into separate files of

abc1.txt
xyz2.txt
xyz3.txt

@echo off
for /f "tokens=1,* delims=-" %%a in ('type "file.txt"') do (
>>"%%a.txt" echo(%%a-%%b
)
pause

Reply

#4
Use the cgwin command SPLIT.

Samples:

-split a file every 500 lines counts:

split -l 500 [filename.ext]

For more: split --help
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through