Do a copy with a time-based filter and not copy "empty" folders


#1

Hello, so what I’m trying to accomplish is to copy some files from an FTP server and say use --max-age 3M to copy only certain files, but not copy any folder that would be “empty” as a result of the filter “–max-age 3M”. What I have been doing so far is running the rmdirs command after the copy is done. Hopefully there’s a way to accomplish this but if not it’s not the end of the world. Great tool by the way!


#2

Hmm, I use --delete-empty-src-dirs for my rclone move, but that moves a file in a directory and if empty, it will delete it at the end.

I didn’t think rclone copied empty directory as there is a bug related to that here:

Are you seeing something different in trying it out?


#3

Hi Animosity022,

Thanks for the reply. What I’m experiencing is the following:

Source is an FTP Server Destination is a Team Drive and this is the command I’m using:

rclone copy ftpserver:firmware teamdrive:firmware -v --stats=1s --stats-file-name-length 0 --max-age 3M --transfers=1 --checkers=1 --size-only --timeout=1m --delete-excluded

Source folder structure (very simplified)

Firmware/
Folder A/
File 1.txt is younger than 3 months
File 1.txt is younger than 3 months

Folder B/
File 1.txt is older than 3 months
File 2.txt is older than 3 months
Folder B1/
File 3.txt is older than 3 months

After the transfer at the destination I get this:

Firmware/
Folder A/
File 1.txt is younger than 3 months
File 1.txt is younger than 3 months

Folder B/ (Empty)
Folder B1/ (Empty)

What I’m trying to accomplish is not getting Folder B at my destination. The reason is that there are a lot of folder and the rmdirs command takes a while to delete them. I added the --delete-excluded in hopes it would accomplish this but it didn’t.


#4

I think this is probably this issue

does that look familiar?


#5

Yes! That is the behavior I was trying to describe. Thanks! I will follow that thread on Github.


#6

Just wanted to let anyone reading this that the latest beta as of March 11 2019 takes care of this issue. The beta version I tested with was rclone-v1.46.0-066-g415eeca6-beta-windows-amd64.