Answer the question
In order to leave comments, you need to log in
How to create and transform a directory tree into .json using bash?
Hello
How can I create and transform a directory tree into .json using bash?
I think the point is clear. Basically, I get recursively the paths of all the files in my directory. But then the problem arises: how to create a competent .json file from all this?
Tried to use JSHON - does not work.
help me please
Answer the question
In order to leave comments, you need to log in
Is it necessary to do this in bash? Try python, it will be much easier and clearer there.
You need to write a couple of functions, one of which is recursive. One function is responsible for outputting a directory, and the other one is responsible for outputting a file. The directory function calls itself for directories and the file function for files. And the file function returns the path to the file.
You just display the file tree on the screen without any json using these functions. When it's done, you'll see where you need to insert parentheses, commas, and quotes to make json out of this.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question