Remove multiple files at once

I've made a (beginner) mistake of not using --dry-run and copied a huge amount of files to my root folder. I'm not used to rclone not keeping the directory structure, but that's on me.
I need to undo the said mistake, but it would take a lot of time to delete these files by hand. Is there a way to throw the filenames into a .txt and use it to compare with the content on my root directory and, if they match, delete it?

hello and welcome to the forum,

to get a list of files
rclone lsf /path/to/folder --files-only > files.txt
and then see what would be deleted, without deleting any files
rclone delete / --files-from=files.txt --dry-run -vv

if you want rclone to ask you about each file, use
https://rclone.org/docs/#interactive

1 Like

What does the / in the second command do? After uploading the folder (and not its contents to the root, like I did yesterday), I've tried using delete at the root, but it is executed recursively and deletes all content from all folders.
The documentation states that " rclone delete only deletes files but leaves the directory structure alone", and the way I interpreted it is that it will delete every file, but when it finds a folder it won't delete anything inside, it will just keep seeking other files.

rclone delete has to know where to delete files from, you wrote that the files you wanted to delete were in my root folder, so i assumed that was /. whatever folder you want to delete from, you have to tell rclone.

that is correct but the documenation also states "it obeys include/exclude filters so can be used to selectively delete files" and that is what the second command does, it only deletes files that are listed in files.txt.
as you wrote "throw the filenames into a .txt and use it to compare with the content on my root directory"
by default, rclone lsf does not recurse, so files.txt would contains filenames only from the root of /path/to/folder.

the first command creates a list of filenames,
the second command deletes the filenames in the files.txt from the root folder /

to be a little more paranoid, i might change the commands to be

rclone lsf  /path/to/folder --files-only --absolute > files.txt
rclone delete / --files-from=files.txt  --max-depth=1 --dry-run -vv

rclone will delete the files inside folders and subfolders.
rclone will not delete the folders themselves.

1 Like

Thanks for the help! Your instructions worked flawlessly! I just started caring more about backups and rclone is being really helpful. I'll keep exploring this awesome tool and, when I have a question, I'll make sure to ask here. Bye!

great!
as for backups, rclone has --backup-dir to have forever forward incremental backups.

i run rclone on my android phone and i use it to backup my andOTP and keepass databases.

here is a script i use for keepass

dt=`date +%Y%m%d.%I%M%S`

source=/storage/emulated/0/keepass/
dest=remote:keepass/backup/
backupdir=remote:keepass/archive/$dt

rclone copy $source $dest --backup-dir=$backupdir
rclone cryptcheck $source $dest