I think that’s easier said than done…I had to fight with this for quite a bit, before coming up with the very ugly expression. I feel that there is probably some much simpler way that I’m overlooking. The “4” in “of (4, it) of file ‘c:\temp\test2.txt’” can be modified to split the file into any number of partitions.
(item 0 of it, item 3 of it) of (integers in (0, item 0 of it - 1 ), item 0 of it, number of lines of item 1 of it, lines of item 1 of it) whose ((line number of item 3 of it - 1) >= (item 2 of it / item 1 of it) * item 0 of it AND (line number of item 3 of it - 1) < item 2 of it / item 1 of it * (item 0 of it + 1)) of (4, it) of file "c:\temp\test2.txt"
For a 1000-line host file, this gives results of the form
A: 0, host1
A: 0, host2
A: 0, host3
A: 0, host4
...
A: 0, Host249
A: 0, Host250
A: 1, Host251
A: 1, Host252
A: 1, Host253
...
A: 1, Host499
A: 1, Host500
A: 2, Host501
A: 2, Host502
A: 2, Host503
...
A: 2, Host748
A: 2, Host749
A: 2, Host750
A: 3, Host751
A: 3, Host752
In this result, item 0 gives “which partition in which to place the line” and item 1 gives “the line to place the partition”. I was pleasantly surprised that this evaluated my 1000-line file in only 20 ms, I expected quite a bit more given that the file must be read at least four times.
I haven’t put it into an Action to test yet, but I think the following actionscript should (on Windows) create files “output0.txt”, “output1.txt”, “output2.txt”, and “output3.txt”, with each file containing one fourth of the source file:
delete __appendfile
appendfile {concatenation "%0d%0a" of ("echo " & item 1 of it & " >> output" & item 0 of it as string & ".txt") of (item 0 of it, item 3 of it) of (integers in (0, item 0 of it - 1 ), item 0 of it, number of lines of item 1 of it, lines of item 1 of it) whose ((line number of item 3 of it - 1) >= (item 2 of it / item 1 of it) * item 0 of it AND (line number of item 3 of it - 1) < item 2 of it / item 1 of it * (item 0 of it + 1)) of (4, it) of file "c:\temp\test2.txt"}
delete BuildOutput.cmd
move __appendfile BuildOutput.cmd
delete output0.txt
delete output1.txt
delete output2.txt
delete output3.txt
waithidden BuildOutput.cmd