born Posted March 27, 2023 Share Posted March 27, 2023 Does anybody have an idea, how to loop through a directory and writing the content of a textfile (like the one attached) without the semicolons into normal lists? Thanks for help. Achimch1-amp-envs.txt Quote Link to comment Share on other sites More sharing options...
opmo Posted March 27, 2023 Share Posted March 27, 2023 example please, how the data should look like. 0 1-amp-env 1 11000; 11000 1-amp-env 1 6000; 6000 1-amp-env 0.2 10000; 10000 1-amp-env 1 5000; ... output: ? Quote Link to comment Share on other sites More sharing options...
born Posted March 28, 2023 Author Share Posted March 28, 2023 0 1-amp-env 1 11000; 11000 1-amp-env 1 6000; 6000 1-amp-env 0.2 10000; 10000 1-amp-env 1 5000 should change to 0 1-amp-env 1 22000; 22000 1-amp-env 1 12000; 12000 1-amp-env 0.2 20000; 20000 1-amp-env 1 10000 These are sequencer files from Puredata in which I'd like to change the timestamps in msecs to double time. Input is a txt document and the output should be a txt document as well. The reason for this approach is that I have quite a few of this files to change ... Quote Link to comment Share on other sites More sharing options...
opmo Posted March 28, 2023 Share Posted March 28, 2023 The file contents need to be a string. (defun remove-semicolon (string) (remove ";" string :test #'string=)) (setf orig "0 1-amp-env 1 11000; 11000 1-amp-env 1 6000; 6000 1-amp-env 0.2 10000; 10000 1-amp-env 1 5000;") (setf pd1 (string-to-list (remove-semicolon orig))) (setf pd2 (gen-divide 4 pd1)) (setf pd3 (loop for i in pd2 collect (list (* 2 (1~ i)) (2~ i) (3~ i) (* 2 (4~ i))))) (join-string-list (loop for i in pd3 collect (string-replace " ;" ";" (join-string-list (list (list-to-string i) ";"))))) => "0 1-amp-env 1 22000; 22000 1-amp-env 1 12000; 12000 1-amp-env 0.2 20000; 20000 1-amp-env 1 10000;" Quote Link to comment Share on other sites More sharing options...
born Posted March 29, 2023 Author Share Posted March 29, 2023 That looks really good. Thanks a lot. Achim Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.