- AuthorPosts
- April 1, 2009 at 6:06 pm #7116topic7Member
i have one 5000 line text file.
i want to make 50 files that has 100lines.
what will i do?April 2, 2009 at 6:10 pm #7119Yutaka EmuraKeymastertopic7 wrote:
i have one 5000 line text file.
i want to make 50 files that has 100lines.
what will i do?Please use a macro to do that kind of routine works.
April 14, 2009 at 4:17 pm #7144PanchoMembertopic7 wrote:
i have one 5000 line text file.
i want to make 50 files that has 100lines.
what will i do?try this: (change ‘ Number of lines for each ‘ to 100)
if( !editor.EnableTab ){
editor.EnableTab = true;
alert( “Please run this macro again.” );
Quit();
}sPath = document.FullName; // Set the root folder where you want to save the split files. It must already exist.
// The result files will be save as “1.txt”, “2.txt”, “3.txt”, … in this folder.
// If the same file names already exist, these files will be overwritten!
i = 1;
Redraw = false;
while( 1 ) {
docSearch = editor.ActiveDocument;
editor.NewFile();
docResult = editor.ActiveDocument;
docSearch.Activate();
docSearch.selection.StartOfDocument();
docSearch.selection.LineDown( true, 100000 ); // Number of lines for each split file to contain
sLine = docSearch.selection.Text;
if( sLine == “” ){
docResult.Close();
break;
}
docSearch.selection.Delete(1);
docResult.Activate();
docResult.selection.Text = sLine;
docResult.Save( sPath + ‘_’+i + “.txt” );
i++;
docResult.Close();
docSearch.Activate();
}
Redraw = true;
powered by YutakaApril 14, 2009 at 4:49 pm #7145PanchoMember[deleted]
- AuthorPosts
- You must be logged in to reply to this topic.