Command 1: Moving Files Based on Filename Keywords
The command:
- find /path/to/pdfs -regex '.*Test.*\.pdf\|.*UE.*\.pdf\|.*keyword1.*\.pdf\|.*keyword2.*\.pdf' -exec mv {} /path/to/destination \;
Important Note: This command moves the files. The original files will be removed from their original location.
Command 2: Copying Files Based on Filename Keywords
The command:
- find /path/to/pdfs -regex '.*Test.*\.pdf\|.*UE.*\.pdf\|.*MT765.*\.pdf\|.*765.*\.pdf' -exec cp {} /path/to/destination \;
Important Note: This command copies the files. The original files are preserved in their original locations.
Caveats:
Both commands are case-sensitive. If you need a case-insensitive search, replace -regex with -iregex. Also, these commands move or copy anything within the specified folder that matches the filename pattern. pdf, so make sure the provided keywords are specific enough to avoid unintended actions. For more advanced scenarios or error handling (e.g., what happens if the destination directory doesn't exist?), more sophisticated scripting (using bash or other shell scripting languages) is recommended.