Answer the question
In order to leave comments, you need to log in
How to automate the movement of files with conditions?
To optimize the space, you need to solve the problem of constantly moving files from 1 folder to a backup for a period (in case the author suddenly asks) for 3 months, followed by deletion.
Answer the question
In order to leave comments, you need to log in
Bash is endowed with all the necessary features in combination with find
. Specify the question.
something like this ?
Create a backup folder
mkdir /tmp/backup
find /home/bitrix/ext_www/shop.ru/ -mtime -30 -regex ".*\.\(jpg\|jpeg\|gif\|png\|JPG\|JPEG\|GIF\|PNG\)" -print0 | xargs -0 cp --parents --target-directory /tmp/backup
find
- recursive search /home/bitrix/ext_www/shop.ru/
- where to look for -mtime -30
- values that were created in the last 30 days can also take positive values. -regexp
not necessarily just showed if you need only certain files, -print 0
you don’t really need it, but if you don’t just have files there, but a directory structure with attachments, then through the print we transfer to xargs in short, all directories will be created normally xargx
- explain for a long time |
- transfer to cp --parents --target-directory
copies creating a /tmp/backup
directory directory itself . Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question