Skip to content

Instantly share code, notes, and snippets.

@lucmann
Created December 28, 2021 04:44
Show Gist options
  • Save lucmann/8a806fb3f9be74806aecdb8f28c44e40 to your computer and use it in GitHub Desktop.
Save lucmann/8a806fb3f9be74806aecdb8f28c44e40 to your computer and use it in GitHub Desktop.
rename files in bulk
find -name 'ARB-*.md' -printf '%P\n' | awk '{orig=$0; gsub(/-/, "_"); print "mv", orig, $0}' | bash
# notes
#
# -printf '%P\n' to strip preceding './' from find's output
# orig=$0 to save original file name
# gsub(/-/, "_") to subsititue '-' in the original file name to '_' in the target file name, it happens to '$0' in place
# print "mv", orig, $0 to generate shell command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment