Skip to content

Instantly share code, notes, and snippets.

@lipengzhou
Created July 24, 2020 08:50
Show Gist options
  • Save lipengzhou/71dda349faca45c84c4ec71514591664 to your computer and use it in GitHub Desktop.
Save lipengzhou/71dda349faca45c84c4ec71514591664 to your computer and use it in GitHub Desktop.
const fs = require('fs')
const files = fs.readdirSync('./')
const trecFiles = files.filter(file => file.endsWith('.mp4'))
const start = 1
trecFiles.forEach((item, index) => {
let seq = start + index
if (seq < 10) {
seq = `0${seq}`
}
fs.renameSync(item, `${seq} ${item.split(' ')[1]}`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment