<p>I figure out a solution thanks to Brad's suggestion to update the asset indexes. That allowed me to find all assets on the server that contained a partial match to my LogID number which I am passing in a URL string. </p>

CC BY-SA 3.0
2017-07-09T00:29:59.940Z
2017-07-09T00:29:59.940Z
Lori
<p>Is it possible to search a server folder containing image and video files that were previously uploaded via ftp and then loop through those files in the entry template?</p>

<p>Each entry has a unique Log ID number field which is also part of the image or video filename.</p>

<p>Example:</p>

<ul>
<li>Log ID: <strong>12345</strong></li>
<li>Image filename: <strong>12345</strong>-[8374]-img-01.jpg</li>
<li>Image filename: <strong>12345</strong>-[8374]-img-02.jpg</li>
<li>Video filename: <strong>12345</strong>-[8374]-vid-01.mp4</li>
<li>etc...</li>
</ul>

<p>Conceptually on the template page...</p>

<ul>
<li>Grab the entry LogID field (ex. "12345")</li>
<li>Search the media server folder for all filenames that begin with the LogID</li>
<li>Display all of the found images and videos</li>
</ul>

<p>I found <a href="https://craftcms.stackexchange.com/questions/19043/auto-add-images-to-entry-after-ftp-to-server">this question</a> which is very similar but I don't have the skills to write a plugin. </p>

CC BY-SA 3.0
2017-07-06T23:23:51.347Z
Any reason you couldn't Settings->Tools->Update Asset Indexes after every FTP upload and deal with the uploads as proper Craft Assets?
Brad Bell
CC BY-SA 3.0
2017-07-07T01:10:40.390Z
@BradBell do you mean then open each entry and attach the uploads? If that's what you mean, I could, but we upload about 200 files every week for about 50 preexisting entries.  I was hoping that there may be another way to do it automatically.
Lori
CC BY-SA 3.0
2017-07-07T03:57:31.840Z
Well... there is, but it's going to require a plugin. :)  I can't think of any other way.
Brad Bell
CC BY-SA 3.0
2017-07-08T14:12:20.390Z
@BradBell I wonder if I misunderstood your initial suggestion about using "Update Asset Indexes" tool. If I index the files so they exist in the database, they can be searched, correct? So in my template, could I grab the LogID field value from the page entry and then used that value to search the assets folder for filenames that contain that LogID?
Lori
<templating><assets><search><forloop><loop>
Search then loop through files that were uploaded via FTP
# Search then loop through files that were uploaded via FTP

(Asked by: username_0 on 2017-07-06)

Is it possible to search a server folder containing image and video files that were previously uploaded via ftp and then loop through those files in the entry template?

Each entry has a unique Log ID number field which is also part of the image or video filename.

Example:

* Log ID: **12345**
* Image filename: **12345**-[8374]-img-01.jpg
* Image filename: **12345**-[8374]-img-02.jpg
* Video filename: **12345**-[8374]-vid-01.mp4
* etc...

Conceptually on the template page...

* Grab the entry LogID field (ex. "12345")
* Search the media server folder for all filenames that begin with the LogID
* Display all of the found images and videos

I found [this question](https://craftcms.stackexchange.com/questions/19043/auto-add-images-to-entry-after-ftp-to-server) which is very similar but I don't have the skills to write a plugin.

**Tags:** templating, assets, search, forloop, loop

> **Comments:**
> **username_1**: Any reason you couldn't Settings->Tools->Update Asset Indexes after every FTP upload and deal with the uploads as proper Craft Assets?  
> **username_0**: @BradBell do you mean then open each entry and attach the uploads? If that's what you mean, I could, but we upload about 200 files every week for about 50 preexisting entries.  I was hoping that there may be another way to do it automatically.  
> **username_1**: Well... there is, but it's going to require a plugin. :)  I can't think of any other way.  
> **username_0**: @BradBell I wonder if I misunderstood your initial suggestion about using "Update Asset Indexes" tool. If I index the files so they exist in the database, they can be searched, correct? So in my template, could I grab the LogID field value from the page entry and then used that value to search the assets folder for filenames that contain that LogID?  

---

## 1 answers

### Answer by username_0 on 2017-07-09. Score: 1 | Accepted answer

I figure out a solution thanks to Brad's suggestion to update the asset indexes. That allowed me to find all assets on the server that contained a partial match to my LogID number which I am passing in a URL string.


---

