user2152545
user2152545

Reputation: 21

Save each line as separate .txt file

How in notepad do I save as such

Filename: Original.txt:

[email protected]
[email protected]
[email protected]

--With Your Help--

Filename: 1.txt

[email protected]

Filename: 2.txt

[email protected]

Filename: 3.txt

[email protected]

Upvotes: 2

Views: 5466

Answers (2)

jfa
jfa

Reputation: 1101

I don't know of any notepad++ plugins or anything, but that is about 4-10 lines of code in Python or most other languages.

Loop:, Make new txt file, paste line

Next line, repeat.

Is there a particular reason you want it to be Notepad++ specific?

Edit:

I was intrigued by this idea so I went ahead and wrote it.

yourfile = open('YOUR.TXT', 'r')
counter = 0
magic = yourfile.readlines()

for i in magic:
    counter += 1
    newfile = open(('EMAILS' + str(counter) + '.TXT'), "w")
    newfile.write(i)
    newfile.close()

Unfortunately I don't know any .NET languages, but if you could write this in VBasic you could make this a macro in Notepad++ if its something you do regularly.

Upvotes: 1

Phil
Phil

Reputation: 6679

I would write a simple PowerShell script for this:

$counter = 1

Get-Content "myfile.txt" | foreach {
    Set-Content -Path "$counter.txt" -Value $_
    $counter++
}

I don't know of any notepad++ specific solution as I don't use it, but I bet there's a way to run PowerShell scripts from any good programmer-friendly text editor.

Upvotes: 5

Related Questions