Option to copy empty directories to team drives?

I’m running the latest beta version of rclone and just noticed that empty directories did not get copied into our team drives. I found a discussion in the rclone repo related to this and i believe there was mention of including that feature in v1.37 but I can’t recall exactly. Does anyone know if there’s a workaround that will allow us to copy empty directories to team drive?

We’re trying to migrate off our old WinServ2012R2 file server since it is not as heavily used as we originally anticipated. I’d like the folder structure on the file server to stay in tact even if the directories are empty. Our users get confused really easily and I have a feeling IT is going to get blamed for “missing” files if we don’t leave everything as-is.

Crude but on Linux I would run a find command too locate all the empty directories and put a file in them with a specific name, sync it, then delete all occurrences of that file leaving the empty directories… I’m sure you can accomplish that with powershell on Windows but not sure.

Thanks. I guess that will work if it’s not currently supported. I’ll give that a go. Shouldn’t be too hard with powershell.

Make sure you create files that are greater than zero bytes…

well, it was kind of annoying but i ended up doing what you recommended. Ran a powershell command to find all empty directories, created a new file with a single line. Ran rclone sync, ran another powershell command to delete the temp file, ran another rclone sync command. :’(

Perhaps post your code so others could use it if they have similar requirement until rclone can handle this directly.

Yeah, it’s nothing special but for reference in case anyone’s interested I just did something like this:

$shares = “Marketing”,“HR”,“Sales”,“Customer Service”, “Operations” foreach ($share in $shares) {$dirs = Get-ChildItem -Path “\path\to\share$($share)” -directory -recurse
$emptyDirs =$dirs | where {$_.GetFiles().Count -eq 0} | Select FullName }$emptyDirs | % {New-Item $_.FullName -ItemType file -Name temp.txt -Value “This is a string.”} That portion creates the file in any empty directories from the list of shares being checked. After this, i run the first rclone sync then I run this line of code:$emptyDirs | % {
$path = set-location$_.FullName
Remove-Item * -Include *.txt
}

Not the cleanest, but I just needed something quick that works.

1 Like

We are edging ever closer to fixing this in the long running #100. I was hoping to get it done for 1.37 but I’m going to have to punt it to 1.38.

@ncw Has this been implemented in 1.38? Im looking at the release notes and it looks like the ability to automatically delete empty directories was added but doesn’t appear to be a way to copy over empty directories. Only reason I don’t want to create a temp text files in all empty directories, running the rclone sync, then removing the temp files and re-running an rclone sync again is we have some windows shares that have 200GB+ data. Not sure if the sync command will attempt to re-sync everything all over again or just what’s changed.

I’ve only tested on a small dataset and even with that small set, the sync/re-sync still takes a bit of time.

Not yet, though it is planned: https://github.com/ncw/rclone/issues/1837

Only stuff which has changed. It does have to scan all the directories which can take some time though.

cool, thanks for the info. Think I’ll do the workaround for now.