Skip to content

Instantly share code, notes, and snippets.

@andreigec
Created October 21, 2022 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreigec/537f518f4cdd9a954272a819a6f3da74 to your computer and use it in GitHub Desktop.
Save andreigec/537f518f4cdd9a954272a819a6f3da74 to your computer and use it in GitHub Desktop.
import path from 'path'
import fs from 'fs'
var f1=fs.readdirSync("./").filter(x=>x.endsWith(".srt")||x.endsWith(".webm"))
f1.forEach(f=>{
var d1=f.match(/(.*?202[12] )/gim)?.[0]
if (!d1){
return
}
var d2= new Date(d1)
var d3=d2.toISOString().split('T')[0]
var newf=d3+" "+f.substring(d1.length)
console.log("x=",f,newf)
fs.renameSync(f,newf)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment