Skip to content

Instantly share code, notes, and snippets.

@lemajes
Last active July 21, 2024 16:35
Show Gist options
  • Save lemajes/6a0fd1d986089fe9c766eceefb0881a4 to your computer and use it in GitHub Desktop.
Save lemajes/6a0fd1d986089fe9c766eceefb0881a4 to your computer and use it in GitHub Desktop.
  • Find files of today and rsync them to a folder
find ./ -daystart -ctime 0 -print0 | xargs -0 -I{} rsync -avr {} /tmp/blabla/
  • Find files and rename them with regex
find . -type f | perl -pe 'print $_; s/input/output/' | xargs -d "\n" -n2 mv
  • Rename all files named with this convention 'YYYYMMDD.md' to 'YYYY_MM_DD.md'
find /path/to/your/directory -type f -name "*.md" -exec bash -c 'for f; do mv "$f" "$(dirname "$f")/$(basename "$f" | sed -E "s/^([0-9]{4})([0-9]{2})([0-9]{2})\.md$/\1_\2_\3.md/")"; done' bash {} +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment