EmEditor (text editor) Forum Index
   Questions and Answers about EmEditor Core
     Split text file into multiple files based on string
Register To Post

Threaded | Newest First Previous Topic | Next Topic | Bottom
Poster Thread
SSI
Posted on: 9/22/2010 5:47 am
Just popping in
Joined: 9/22/2010
From:
Posts: 2
Split text file into multiple files based on string
This seems more like something a separate utility would be used for but I thought I would ask since EmEditor is such impressive capabilities.

Is it possible to take a single text file in EmEditor and break it into parts, and save each part as a separate text file?

e.g. suppose I had a text file with the following contents:

AXBCDXE

and I wanted to split the file into three parts based on "X" so the first file would just contain "A", the second would contain "BCD" and the third would contain "E". Perhaps optionally the delimiter itself could be included at the beginning or end of each separate file.

Thoughts?
Yutaka
Posted on: 9/22/2010 9:08 am
Webmaster
Joined: 9/28/2006
From: Redmond
Posts: 2401
Re: Split text file into multiple files based on string
Hello SSI,

Here is a JavaScript macro for this purpose:

document.selection.SelectAll();
var textArray = document.selection.Text.split("X");
for( i = 0; i < textArray.length; i++ ){
	editor.NewFile();
	document.write( textArray[i] );
}


I hope this helps.


----------------
Yutaka Emura
Developer of EmEditor
http://www.emeditor.com/

Threaded | Newest First Previous Topic | Next Topic | Top


Register To Post
 
English čeština Deutsch español français italiano 日本語 한국어 Русский 简体中文 繁體中文