Is it possible to create .md files in batch?


Idea is to create a photo-gallery from images organised into folders (a lot of them). I do not want to create a .md file using the admin panel - as I would have to go through each link and save the page. Is it possible to create pages automatically or just add a simple .md file in batch mode?

This is currently not possible with grav or admin plugin.
You could however create a script to create a md file in every folder.

1 Like

Thank you for your answer @paul. I was looking at a Grav (or Grav+Admin) based solution here. You think it is possible to write a plugin that crawls through the folder structure and performs actions based on some rules?

yep that should be doable :slight_smile: @gnat

@RobLui @paul Would really appreciate any pointers showing how this can be achieved.

Haven’t done it myself yet, but should be something in the line of :


  $Directory = new RecursiveDirectoryIterator('path/to/project/');
  $Iterator = new RecursiveIteratorIterator($Directory);
  $Regex = new RegexIterator($Iterator, ‘/^.+\.extention$/i', RecursiveRegexIterator::GET_MATCH);


or / and a combination of:

function getDirContents($dir){
    $results = array();
    $files = scandir($dir);

        foreach($files as $key => $value){
            if(!is_dir($dir. DIRECTORY_SEPARATOR .$value)){
                $results[] = $value;
            } else if(is_dir($dir. DIRECTORY_SEPARATOR .$value)) {
                $results[] = $value;
                getDirContents($dir. DIRECTORY_SEPARATOR .$value);