RyanH
January 12, 2020, 2:35am
1
The command below does not appear to support the deletion of all files on a remote.
rclone lsf dropbox: | xargs -d'\n' -i rclone purge dropbox:{}
It results in the following error message.
Failed to create file system for "dropbox:{filename}.txt": is a file not a directory
My understanding of the purge
command is that is deletes all files and directories at a remote.
The command is expecting a directory not a file as noted in the page you linked
If you want to delete a file, you'd just use delete as purge is for directories and all their contents.
RyanH
January 12, 2020, 3:35am
3
Isn't the remote considered to be the root directory so shouldn't it delete files and directories with their contents?
You mean if you run:
rclone purge dropbox:
?
That would delete your entire dropbox files.
RyanH
January 12, 2020, 3:41am
5
Yes and the command rclone lsf dropbox: | xargs -d'\n' -i rclone purge dropbox:{}
is intended to delete all contents i.e. rclone purge dropbox:
rclone lsf lists files and you can see by the error message, you are trying to delete a file not a directory.
RyanH
January 12, 2020, 3:58am
7
rclone lsf
lists files and directories and given I'm parsing the list with xargs
, shouldn't it be purge it?
Assuming your parse list was doing what you expected, but it's catching a file too:
felix@gemini:/opt/rclone$ rclone lsf GD: | xargs -d'\n' -i rclone lsf GD:{}
191qpocr6dhlo35vn2gk2h8gf4/
95tj3q4gj5ban13ppu0kisguco
d7pe9pia5d9a0tud31p8lkdpi0
fn0jbidpl7cqq9so46diq346so
smu5ej34ujbdoip1cm3mlk92q4/
tnvepu36qiohcun8v84ddhsam0/
rclone.log
felix@gemini:/opt/rclone$ rclone lsf GD:
Wednesday-2019-11-06/
crypt/
rclone.log
The purge is giving you an error message it's trying to delete a file so it's best to step back and see why the message is coming.
RyanH
January 12, 2020, 4:15am
9
Yes, I am expecting it to list files so that they can be purged at the same time.
rclone lsf dropbox:
crypt/
testfile.txt
rclone lsf dropbox: | xargs -d'\n' -i rclone lsf dropbox:{}
bv21aq86kfd39llpd4dctdq5gk/
testfile.txt
rclone lsf dropbox: | xargs -d'\n' -i rclone purge dropbox:{}
Failed to create file system for "dropbox:testfile.txt": is a file not a directory
You can't use purge on files as it's only for directories. You'd have to use delete.
That's why the error message tells you it's a file and not a directory.
RyanH
January 12, 2020, 8:38am
11
Is there a way to combine these as a single command i.e purge and delete?
ncw
(Nick Craig-Wood)
January 12, 2020, 12:26pm
12
If you add --dirs-only
this will stop giving that error, so
rclone lsf --dirs-only dropbox: | xargs -d'\n' -i rclone purge dropbox:{}
This will leave files in the root directory only which you can delete with
rclone delete dropbox:
RyanH
January 19, 2020, 7:14am
13
Thanks @ncw . Does rclone delete remote:path
support redirects?
For example, would rclone delete dropbox:<filelist
be allowed?
ncw
(Nick Craig-Wood)
January 19, 2020, 2:12pm
14
You need to use the --files-from
flag to have a list of paths. These need to be relative to the root
https://rclone.org/filtering/#files-from-read-list-of-source-file-names
RyanH
January 19, 2020, 5:00pm
15
Thanks @ncw . I did attempt that however it returns an error. See below.
rclone deletefile --dry-run --files-from filelist.txt dropbox:
2020/01/19 05:59:02 ERROR : Attempt 1/3 failed with 1 errors and: dropbox: is a directory or doesn't exist
2020/01/19 05:59:02 ERROR : Attempt 2/3 failed with 1 errors and: dropbox: is a directory or doesn't exist
2020/01/19 05:59:02 ERROR : Attempt 3/3 failed with 1 errors and: dropbox: is a directory or doesn't exist
2020/01/19 05:59:02 Failed to deletefile: dropbox: is a directory or doesn't exist
What are the contents of the filelist.txt?
RyanH
January 19, 2020, 5:31pm
17
@Animosity022 - A list of files with new line characters.
For example;
file1.txt
file2.docx
file3.html
ncw
(Nick Craig-Wood)
January 20, 2020, 10:14am
18
You want rclone delete
instead of rclone deletefile
- that should work.
RyanH
January 20, 2020, 4:44pm
19
@ncw , thanks. I'm looking at ways to recursively deleted selected files and hence the sourcing it from a file as opposed to a complete deletion using rclone delete
.
ncw
(Nick Craig-Wood)
January 20, 2020, 6:19pm
20
I meant use rclone delete --files-from ....
- that should work.