Friday, August 26, 2022

Find examples

 A few examples of using the "find" command to make your life easier.


My brother asked about searching through a folder to find images based on date range and then moving them to a new folder.  Sounds simple enough and I'm sure there are multiple ways to accomplish the same thing.  

As for me, I'll keep it simple and run the following little script.


#!/bin/bash
for i in $(find dir_to_search/ -newermt "2011-01-01" ! -newermt "2011-12-31"); do
mv $i /new_dir/
done


Another example of just doing the find for the date range:

find . -type f -newermt 2020-10-01 ! -newermt 2022-10-01






No comments: