Move Files If They Exist Using Bash and Cron

Linux Logo

Move Files If Exist Using Bash and Cron

Script

nano /home/user/scripts/move-files.sh
#!/bin/bash
#Move Files Only If Exist
[ -f /home/user/*.pdf ] && mv /home/user/*.pdf /home/user/pdfs/

Cron

crontab -e
#Every Minute Move *.pdf Files Only If Exist
* * * * * /home/user/scripts/move-files.sh