I recently needed to create a C# class for each file in a folder. This was a one-off job, but there were a large number of files in the folder. How would you approach doing this?
I used the command line to list the files, using the dir
command. I piped the result to the clip
command so the list of files was put on my clipboard rather than the screen.
dir | clip
I then pasted this into my IDE so I could use its multiline editing tool. (I use JetBrains Rider but I'm sure multiline editing is common functionality in most IDEs.) This made it quick and easy to remove the data I didn't need, and turn each filename into a class. I then used Rider to split the classes out into separate files, as is idiomatic in C#.
This was a quick job in the end, and it brought home the value of being familiar and comfortable with the tools at your disposal.