Hi,
One way of doing this is with a command line script that you can run on the server where your content folder resides. To that end I would recommend reading through the following PHP manual links:
- https://www.php.net/manual/en/ref.dir.php - functions for working with directories: specifically opendir, readdir and closedir
- https://www.php.net/manual/en/book.filesystem.php - functions for working with the file system: specifically filemtime for determining the file age, pathinfo for determining the file type by extension, file_exists for determining if a file exists, copy and rename for copying/moving files
You could/should test on some sample data before to make sure you get the desired outcome.
Also don't forget to backup your data :)
On Wed, Jul 17, 2019 at 8:20 PM Matthew Zand <dcwebmakers@xxxxxxxxx> wrote:
Hi,
I have a content folder on my website with more than few thousand images and videos. I want to write php code to do following:
1- Read all files on the folder
2- Remove all files that are older than 2 years ago
3- Loop through all content files to check file type and save them in two arrays (one for images and another for videos)
4- Merge new image array files with an existing image folder files but if duplicate exists, override the older version of file.
What is best way to achieve this?
--