How to iterate through directory and concatenate names of folders into string

flüber _

Similar to this question, but with folder names instead of with file names. The current code I have for concatenating files is

setlocal enabledelayedexpansion
set colorFileNames=
for %%f in (%CD%\automation\*) do (
  set _file=%%~nf
  if [!colorFileNames!]==[] (
    set colorFileNames=!_file!
    ) else (
    set colorFileNames=!colorFileNames!, !_file!
    )
)

which outputs something like fileName1, fileName2, ..., fileNameN but it obviously only works with files. How would I modify it to use folder names instead of file names?

flüber _

I changed a few things to make it work:

setlocal enabledelayedexpansion
set graphicsSets=
for /D %%f in (%CD%\automation\*) do (
  set _folder=%%~nf
  if [!graphicsSets!]==[] (
    set graphicsSets=!_folder!
    ) else (
    set graphicsSets=!graphicsSets!, !_folder!
    )
)

The /D tells the loop to go over directories instead of files, and I replaced what was in the () with just the path to the folder I was looping in. Everything else is the same, so not too difficult of a modification.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to iterate through folder and add names of files to a single string variable

From Dev

batch: Iterate through directories and get directory names

From Dev

how to load folders names in a directory to an observable collection?

From Dev

jq - How to iterate through keys of different names

From Dev

Iterate over files in directory, create folders based on file names and move files into respective folders

From Dev

How to increment or loop through the folders in a specific directory

From Dev

Iterate through file names

From Dev

FOR loop to iterate through two folders

From Dev

iterate a directory and find only file whose names start with the certain string

From Dev

Concatenate a string to column names

From Dev

How to iterate through chars of a string in Postgresql?

From Dev

How can I iterate through the property names of the prototype of an html element?

From Dev

Qt 4.7 - How to iterate through files in an FTP directory

From Dev

How to iterate through every directory specified and run commands on files (Python)

From Dev

How to iterate through directory and move particular files to a different folder

From Dev

How to iterate through subdirectories in a directory and count the files in the subdirectories in python

From Dev

How to iterate through a directory and sub-directories using a URL

From Dev

Iterate through string in register

From Dev

Recursively iterate through files in a directory

From Dev

Iterate Through Folders/Subfolders/Files in Google Drive

From Dev

Iterate through folders that start with the same name

From Dev

How can I iterate through a list of strings in Python and concatenate the ones that belong to a tag?

From Dev

How to iterate through characters in a string in Rust to match words?

From Dev

How to iterate through string one word at a time in zsh

From Dev

how to iterate through a folder writing each folder name into a string array

From Dev

How to iterate through string one word at a time in zsh

From Dev

How to iterate through very large string arrays in Android?

From Dev

jQuery: How to iterate through JSON encoded string (array)

From Dev

How to iterate through Array and remove an item based off a string value

Related Related

  1. 1

    How to iterate through folder and add names of files to a single string variable

  2. 2

    batch: Iterate through directories and get directory names

  3. 3

    how to load folders names in a directory to an observable collection?

  4. 4

    jq - How to iterate through keys of different names

  5. 5

    Iterate over files in directory, create folders based on file names and move files into respective folders

  6. 6

    How to increment or loop through the folders in a specific directory

  7. 7

    Iterate through file names

  8. 8

    FOR loop to iterate through two folders

  9. 9

    iterate a directory and find only file whose names start with the certain string

  10. 10

    Concatenate a string to column names

  11. 11

    How to iterate through chars of a string in Postgresql?

  12. 12

    How can I iterate through the property names of the prototype of an html element?

  13. 13

    Qt 4.7 - How to iterate through files in an FTP directory

  14. 14

    How to iterate through every directory specified and run commands on files (Python)

  15. 15

    How to iterate through directory and move particular files to a different folder

  16. 16

    How to iterate through subdirectories in a directory and count the files in the subdirectories in python

  17. 17

    How to iterate through a directory and sub-directories using a URL

  18. 18

    Iterate through string in register

  19. 19

    Recursively iterate through files in a directory

  20. 20

    Iterate Through Folders/Subfolders/Files in Google Drive

  21. 21

    Iterate through folders that start with the same name

  22. 22

    How can I iterate through a list of strings in Python and concatenate the ones that belong to a tag?

  23. 23

    How to iterate through characters in a string in Rust to match words?

  24. 24

    How to iterate through string one word at a time in zsh

  25. 25

    how to iterate through a folder writing each folder name into a string array

  26. 26

    How to iterate through string one word at a time in zsh

  27. 27

    How to iterate through very large string arrays in Android?

  28. 28

    jQuery: How to iterate through JSON encoded string (array)

  29. 29

    How to iterate through Array and remove an item based off a string value

HotTag

Archive