june4
89 天前
我以前写过一个,找了下还在 注意这里我转的文件都是\r\n 换行的,你看你的情况可能要改一下
#!/usr/bin/node
const assert = require('node:assert/strict')
const fs = require('node:fs')
const filename = process.argv[2]
assert(filename, 'Missing filename arg')
console.log('=> Filename:', filename)
const TMP_LINE = '{{TMP_LINE}}'
let content = fs.readFileSync(filename, 'utf-8')
content = content.replaceAll(/\r\n\r\n/g, TMP_LINE + TMP_LINE)
content = content.replaceAll(/\r\n/g, '')
content = content.replaceAll(TMP_LINE, '\n')
fs.writeFileSync(filename + '.joined', content)