Move Folder if specific sub folder name exists

The rclone version etc doesn't matter since I am asking a general question.

Here is example:

I have a Movie Dump folder.

I want to find all parent folders which contain a sub folder called
Featurettes

Then I want to move all the Parent Folders with sub folders etc that contain that word. So basically maintain the folder structure.

Can this be done natively with rclone, or is a script needed?

If a script is needed does one exist?

My goal would be to use command line without mounting the the drives themselves.

rclone -v move remote1:/Movies/MovieDump/ remote1:/Movie/MovieFeaturettes/

I use windows, but also have WSL2 running, so can run windows or nix scripting

Forgot to mention, when I search for Sub Folder, I only want to search 1 level deep meaning got into each folder in the given path, and only search/find search word inside that folder, do not iterate through many levels if they exist

Unix scripting follows...

First find the parent directories. You have to find the files in those directories then remove the file names.

rclone lsf -R --files-only --include "**/Featurettes/**" remote1:/Movies/MovieDump/  | sed 's/\/Featurettes\/.*$//' | sort | uniq > parents

Check the parents file looks OK

Next iterate through those parents moving them one at a time from MovieDump to MovieFeaturettes

while IFS= read -r line; do
    echo "moving $line"
    echo rclone --dry-run move -v "remote1:/Movies/MovieDump/$line" "remote1:/Movie/MovieFeaturettes/$line"
done < parents

Remove the echo from in front of rclone move when happy. Then remove --dry-run when happy.

Thanks this is huge time saver !

1 Like

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