Created
March 17, 2016 01:47
-
-
Save JamesSkemp/3a7bae02deb5fd55ea45 to your computer and use it in GitHub Desktop.
Create README.md with PNG images from a directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
// Can run in LINQPad. | |
var directory = @"C:\Users\James\Projects\directory" + Path.DirectorySeparatorChar; | |
parsePngFiles(directory); | |
} | |
// Define other methods and classes here | |
void parsePngFiles(string directory) | |
{ | |
var directoryInfo = new DirectoryInfo(directory); | |
var pngFiles = directoryInfo.GetFiles("*.png"); | |
if (pngFiles.Any()) | |
{ | |
StringBuilder readmeText = new StringBuilder(); | |
//readmeText.AppendFormat("# {0} {1}" + Environment.NewLine, directoryInfo.Name, directoryInfo.Parent.Name); | |
readmeText.AppendFormat("# {0}" + Environment.NewLine, directoryInfo.Name); | |
foreach (var pngFile in pngFiles) | |
{ | |
readmeText.AppendFormat("" + Environment.NewLine, pngFile.Name); | |
} | |
File.WriteAllText(directoryInfo.FullName + "README.md", readmeText.ToString()); | |
} | |
var subFolders = directoryInfo.GetDirectories(); | |
if (subFolders.Any()) | |
{ | |
foreach (var subFolder in subFolders) | |
{ | |
parsePngFiles(subFolder.FullName + Path.DirectorySeparatorChar); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment