Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Open Question: Question about “for” loop in batch?

batch loop
0
Posted

Open Question: Question about “for” loop in batch?

0

batch scripting question. I am trying to use a FOR loop to receive a list of every file names in a directory. I want to then output them to a file. What I have currently is: for /r “public” %%g in (*) do echo ^ %%~nxg ^^^ >> public\index.html for each file within the sub-folder of the one from which the batch script is run… echo (etc.) to the file index.html in the public folder, which again, is a sub-folder of the one from which this script is run. What I would LIKE to do… is to have the exact same list but with a path, RELATIVE to the current path. In other words, if I have a file in “public” called “pickles.txt” I want it to JUST echo “pickles.txt”. However, if there is a FOLDER called “hello” which CONTAINS a FILE called “pickles.txt”, I want it to ECHO “hello\pickles.txt”. I know exactly what I want to do, I just don’t know how. I want to look in public\ and receive a list of files… then into each sub-directory, and receive a list of files, and their corresponding sub-direct

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123