Cloud Stack Ninja

apologies in advance if there is already a solution for this somewhere, I was not able to find it.

I have several numbered folders in a directory, each of them have a file "U.txt" that I would like to run a script on. So my file structures are like:

folder
-0
--U.txt
-10
--U.txt
...
-250
--U.txt

I want to recursively go into each folder. I am aware you can do this with glob, I so I can get past that part, I'm just unsure of how to save them all into one file, with their file names numbered. So I want to save the new U.txt, (which will be a .npy file), into a new folder like

U_0.npy
U_10.npy
...
U_250.npy


Read more here: https://stackoverflow.com/questions/64190264/saving-files-after-recursively-running-script-in-subdirectories

Content Attribution

This content was originally published by user3611 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: