Created
July 30, 2012 14:15
-
-
Save chenfengyuan/3207186 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun split-per-3-lines (directory prefix suffix) | |
(interactive | |
(let (d p s) | |
(setq d (read-directory-name "Directory : ")) | |
(setq p (read-string "prefix : ")) | |
(setq s (read-string "suffix : ")) | |
(list d p s))) | |
(save-excursion | |
(goto-char (point-min)) | |
(let ((triplets | |
(loop | |
with pre = 1 | |
for i from 0 | |
do (forward-line 3) | |
collect (list pre (point) i) | |
do (forward-line) | |
do (setq pre (point)) | |
until (= (point) (point-max))))) | |
(dolist (triplet triplets) | |
(let ((s (car triplet)) | |
(e (cadr triplet)) | |
(i (caddr triplet))) | |
(write-region s e (format "%s/%s%06d%s.txt" directory prefix i suffix))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment