Skip to content

Instantly share code, notes, and snippets.

@tayiorbeii
Created November 7, 2022 18:48
Show Gist options
  • Save tayiorbeii/c6407ed88ba665f23a7f95a2f60b4d85 to your computer and use it in GitHub Desktop.
Save tayiorbeii/c6407ed88ba665f23a7f95a2f60b4d85 to your computer and use it in GitHub Desktop.
import "@johnlindquist/kit"
let replaceAll = await npm('just-replace-all')
// Name: renumber-filenames-by-one
// Author: Taylor Bell
// Description: Add one to the numbered filenames dropped in
let files = await drop()
for (let f of files) {
let num = parseInt(f.name.match(/^[0-9]+/)[0])
let newName = replaceAll(f.name, `${num}`, `${num+1}`)
await exec(`mv "${f.path}" "${f.path.split(f.name)[0]}${newName}"`)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment