Copy Directory Structure without any file

Hi,

I wanted to know if rclone can somehow copy a directory structure from my google drive (e.g : TVS/S01/fileA) to another remote drive without copying the actual file itself(fileA). So just the "skeleton copy". If not, maybe it's possible in the future?

Rclone generally copies files so there isn't anything stock that does that.

There are a number of ways to script something like that though and just create files with a mount.

It depends on your OS though.

What's the point of copying only the structure though?

hello and welcome to the forum,

on windows
rclone mount gdrive x:
xcopy c:\path\to\local\folder x:\folder\ /t /e

on linux
rclone mount gdrive: /mnt/gdrive
for dir in *; do mkdir ~/mnt/gdrive/"$dir"; done

That just copies the top directory and not the entire directory structure though.

1 Like

ok. thanks, i am working on my linux skills.

this will work, really.
cd $source && find . -type d -exec mkdir -p -- $dest/{} \;

1 Like

The xcopy solution for Windows is probably the faster one, so go with that if you are using mounts. For an alternative solution, using rclone mkdir without mounts, you could utilize PowerShell with something like this:

rclone lsjson source_remote: | ConvertFrom-Json | ForEach-Object { $_ } | Where-Object { $_.IsDi
r } | Select-Object -ExpandProperty Path | ForEach-Object { rclone mkdir destination_remote:/$_ }

(Several ways to write powershell code achieving the same thing, can be made shorter by using the shortcuts such as % for ForEach-Object and ? for Where-Object, select for Select-Object etc. With PowerShell Core installed, you could probably use it on Linux as well.)

2 Likes

Thanks Everyone for the helpful suggestions. I'd taken note of all your feedbacks, appreciate it
I ended up using rsync utility to do this and it works really fast.
rsync -a -f"+ */" -f"- *" "$source" "$target"

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.