D
D
Dmitry Tarasov2019-11-07 14:45:11
PHP
Dmitry Tarasov, 2019-11-07 14:45:11

How to delete old files from Yandex disk?

Hello!
What do I want to do?
I want to backup files, but before uploading a new compressed archive, I need to see how many files are on the disk now and leave 2 out of 3, delete the oldest one, delete it and then upload a new one.
I make such a command on the puff.

system ("curl --user ".$yadisk_email.":".$yadisk_pass." -X PROPFIND -H \"Depth: 1\" https://webdav.yandex.ru/".$yadisc_dir."/");

I get this answer.
/backup/src/HTTP/1.1 200 OK2019-11-07T10:40:50ZsrcThu, 07 Nov 2019 10:40:50 GMT/backup/src/document.docxHTTP/1.1 200 OK832727d0122757f5882bdcb02ea09f572019-11-07T10:43:02Zdocument.docxThu, 07 Nov 2019 10:56:18 GMTapplication/vnd.openxmlformats-officedocument.wordprocessingml.document11161string(955) "/backup/src/HTTP/1.1 200 OK2019-11-07T10:40:50ZsrcThu, 07 Nov 2019 10:40:50 GMT/backup/src/document.docxHTTP/1.1 200 OK832727d0122757f5882bdcb02ea09f572019-11-07T10:43:02Zdocument.docxThu, 07 Nov 2019 10:56:18 GMTapplication/vnd.openxmlformats-officedocument.wordprocessingml.document11161"

I don’t understand how to take all the files from this answer and sort by date, take the oldest one and delete it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Radjah, 2019-11-07
@Radjah

> I want to backup files
Use specialized tools like borgbackup with automatic synchronization via the poison daemon, for example.
> system ("curl...
Is using libcurl for php not an option? https://www.php.net/manual/en/book.curl.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question