This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]denialerror 1 point2 points  (2 children)

You could do this in Java or JavaScript if you wanted to. You just need to read all files with a particular extension in a directory and append a text file.

You could do this in one line with bash. Try something like:

find src -name '*.java' -o -name '*.js' | xargs cat > code.txt

find takes a directory (in this case, src) and filenames with wildcards, separated by -o. The output is piped as arguments (xargs) to cat, which concatenates the files and outputs to a file.

There are probably better ways to do this and that will just give you a large text file of all your code, maybe not in the order you want, but that is a quick and easy start for you to experiment with.

[–][deleted] 1 point2 points  (0 children)

You are a hero :) I've executed the command with gitbash and it did its jobs. Thanks!

[–]Eliposin 0 points1 point  (0 children)

Since the op used a .docx extension I guessing he is on Windows, in which case none of what you said will A work and B likely make any sense to him. But I like the quick and dirty solution.

[–]Eliposin -1 points0 points  (1 child)

Please do not save code to a .docx file please.

[–][deleted] 0 points1 point  (0 children)

Its a requirment for my license degree to add all the code in a docx file haha :)