July 12, 2023

Copy, move or delete recently modified or downloaded files with find

To copy all the pdf files downloaded in the last day to a directory files run:

$ find /home/user/Downloads/*pdf -maxdepth 1 -mtime -1 -print -exec cp -t /home/user/Desktop/files {} +

To move all files, replace cp by mv.

To delete all files modified in the last day in the directory named Downloads:

$ find /home/user/Downloads/* -maxdepth 1 -mtime -1 -print -delete 

Run $ man find<> to learn to adjust each of the options used above.

The programme find was published in 1971 and is copyleft-licensed.


personal computing command-line interface (cli) gnu linux trisquel office applications find wiki shell literacy

No affiliate links, no analytics, no tracking, no cookies. This work © 2016-2024 by yctct is licensed under CC BY-ND 4.0 .   about me   contact me   all entries & tags   FAQ   GPG public key

GPG fingerprint: 2E0F FB60 7FEF 11D0 FB45 4DDC E979 E52A 7036 7A88