What is the problem you are having with rclone?
I need delete by rclone files older then x days but left y files
What is your rclone version (output from
Which OS you are using and how many bits (eg Windows 7, 64 bit)
Windows 10 x64
Which cloud storage system are you using? (eg Google Drive)
The command you were trying to run (eg
rclone copy /tmp remote:tmp)
rclone delete selectel:archive --min-age 45d --max-depth=1 --max-delete=20 -v
The rclone config contents with secrets removed.
A log from the command with the
I know now thats the "--max-delete=20" is not my option, but i cann't find correct one
How do you decide what files are going to be left in your 'y'?
last 20 files as example. if they are older then 45 daysm it is must left anyway. i try to do this
I'm sorry but I'm not following what your logic.
Say you have 30 files per month and 12 months of data.
If you delete anything older than 45 days, you get maybe 1 month of data that's less than the 45 days old.
How does a number of files feed into that?
If you say we have 30 files per month and etc. that's true. But some times we have 0 files per day, some times 5 files per day. So if forgot about how files old, i just need have left last 20 files.
If this possible i can mix this rules
There isn't a native way that I can think of that combines a age + minimum number of files as you'd have to define what files to keep in those 20 files that are left. Just keep the newest?
max-deletes if for sync and not related to this.
You'd probably have to wrap a script around it and create the logic you desire.
Maybe @ncw has something creative as well.
Yeap, i try save 20 newest files as minimum.
I mean i want save files for last 45 days, but minimum last 20 files must be saved.
For now only way what i see is copied files back from cloud to PC, make correction and send it back to cloud. It is so stupid - so i left it for the last decision
If you wanted the most recent 20 files you could do something like this to get the list of the files to delete
rclone lsf --files-only -F tp selectel:archive | sort -r | head -n -20 | cut -d';' -f 2 > files-to-delete
Then delete them with
rclone delete -i --files-from-raw files-to-delete selectel:archive
-i flag for testing.
These are alas unix commands, but you could do something similar in Windows quite easily I'm sure.
I am still need some more time to test all, and after all i show the decision
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.