Skip to content

Instantly share code, notes, and snippets.

@ScottKirvan
Created November 9, 2023 19:26
Show Gist options
  • Save ScottKirvan/233fabed05cef9e1f9b007877b8742e7 to your computer and use it in GitHub Desktop.
Save ScottKirvan/233fabed05cef9e1f9b007877b8742e7 to your computer and use it in GitHub Desktop.
regex - match files with (1), (2), etc in the filename - to clean up photo directories

find . -regex '.*/.*[^.]+ ([1-9])\.[^.]+$' wil list the dup files. Pipe that to a text file, modify it, and source it.

To delete or move a resulting file like, ./IMG_1286 (1).PNG, you'll need to escate the space and parens before you can delete (rm) them.

Example: rm ./IMG_1286\ \(1\).PNG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment