Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: SCD/TXT File merger
name
code content
( var extension, scriptPath, currentDir, sourceFiles, outputFileName; extension = "scd"; // "txt" scriptPath = thisProcess.nowExecutingPath; if (scriptPath.isNil) { "Error: This script must be saved on disk.".error; } { currentDir = scriptPath.dirname; outputFileName = "_merged_." ++ extension; sourceFiles = (currentDir +/+ "*." ++ extension).pathMatch.select { |path| (path.basename != outputFileName) and: { path.basename != scriptPath.basename } }.sort; ("Number of" + "." ++ extension + "files found:" + sourceFiles.size).postln; /* Open the output file once and write content incrementally */ File.use(currentDir +/+ outputFileName, "w", { |outFile| sourceFiles.do { |path| var content, fileName; fileName = path.basename; /* Read */ content = File.readAllString(path); if (content.notNil) { /* Write */ outFile.write("\n/* " ++ fileName ++ " */\n\n" ++ content ++ "\n\n"); ("Appended:" + fileName).postln; } { ("Warning: Could not read" + fileName).warn; } }; "Success! All files merged into:" + outputFileName }) }; )
code description
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change