Answer the question
In order to leave comments, you need to log in
How to get a list of all files in a directory and loop through them?
The camera sends screenshots to me on the sftp server. They are not loaded into the main folder, but tricky *banos and have the path: /folder/camera1/23.09.21/random number/jpg/screenshoot19:57.jpg . I did not find any dependence of random numbers. There is no reference to time, date, or event. Maybe 1, maybe 14, maybe 7. I want to send all these screenshots to the cart and then delete them. My logic is this: set cron every minute and check if there are screenshots in the folder, and if there are new screenshots, then run curl, and then demolish. I need to somehow get a list of all files that have the jpg extension (that is, I won’t know the subfolder in advance) and then run a separate curl request for each. I know how to start curl and cron, no problems, but with the rest - yes.
Question: how correct is my approach?
Question 2: how to get a list of files and then separately perform curl for each?
Answer the question
In order to leave comments, you need to log in
do wget -m ... (read the doc to limit a specific folder, make a local copy with subdirectories), then using for example lftp you delete recursively everything in the folder on ftp (rm -rf supports)
carefully, control errors so that wget works correctly, otherwise it will not download and you will delete it with the next command.
ps I'm hinting, bash is a terribly inconvenient language (and approach, using third-party utilities for any sneeze) for programming, of course you can solve your problem very perversely, but why?
take more convenient languages, because in linux there is probably everything that was invented in principle ... python, for example, does not even require installation, because it already exists on almost all installations.
find /home/avx/Изображения -name "*.jpg" -type f -exec realpath '{}' \;
-- Запрос на выборку всех квартир, свободных на определенную дату
SELECT * FROM Apartment a
WHERE NOT EXISTS (
SELECT 1 FROM Apartment_Dates
WHERE apartment_id = a.id AND ? BETWEEN arrival_time AND departure_time
);
-- Запрос на выборку всех квартир, свободных в определенный промежуток дат
SELECT * FROM Apartment a
WHERE NOT EXISTS (
SELECT 1 FROM Apartment_Dates
WHERE apartment_id = a.id AND
(arrival_time BETWEEN ? AND ? OR departure_time BETWEEN ? AND ?)
);
-- Запрос на выборку всех квартир, занятых в определенный промежуток дат
SELECT * FROM Apartment a
WHERE EXISTS (
SELECT 1 FROM Apartment_Dates
WHERE apartment_id = a.id AND
(arrival_time BETWEEN ? AND ? OR departure_time BETWEEN ? AND ?)
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question