Iterate through folders that start with the same name

Bob

I'm trying to iterate through multiple folders and do something with the mp4 files in them, in one for loop. The folder names are formatted like this:

Book 1; Water
Book 2; Earth
Book 3; Fire

So far I'm going through them manually:

@echo off
for /r %%i in ("Book 1; Water\*.mp4") do (
    echo %%~ni
)
for /r %%i in ("Book 2; Earth\*.mp4") do (
    echo %%~ni
)
for /r %%i in ("Book 3; Fire\*.mp4") do (
    echo %%~ni
)
PAUSE

I prefer a method that reads out Book*\*.mp4 in one go. Is there any way to do this?

Magoo
FOR /d /r "%sourcedir%" %%a IN ("Book*") DO (
 FOR %%b IN ("%%a\*mp4") DO ECHO %%b
)

should produce your list of files - sourcedir contains your starting directoryname.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

FOR loop to iterate through two folders

From Dev

Iterate Through Folders/Subfolders/Files in Google Drive

From Dev

Iterate through struct by variable name

From Dev

iterate through classes on same element

From Dev

iterate through classes on same element

From Dev

Batch File to Loop Through Folders and Copy Folder & Contents to Directory with Same Folder Name

From Dev

iterate through select dropdowns with same class name to find selection of specific option

From Dev

How to iterate through multiple child nodes with same name in a json response using C# and assert right content

From Dev

List folders with the same name in the same directory - Delphi

From Dev

Iterate through folders, then subfolders and print filenames with path to text file

From Dev

S3 Iterate through Bucket/Folders/Files

From Dev

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

From Dev

Python iterate through df to create folders and copy files

From Dev

iterate through an enum type initialized with a string name?

From Dev

Batch command move png files to folders same name files and folders

From Dev

delete folders with the same name as the parent folders recursively in bash?

From Dev

Moving files with the same name to matching named folders

From Dev

Same name of two images in different folders of NSBundle

From Dev

Exclude/Include folders differently with the same name in sublime

From Dev

batch copy/move files to folders with same name

From Dev

Windows Phone Classes with same name but different folders

From Dev

filesyncprovider creates folders for documents with same name as document

From Dev

Delete content of folders with same name in different subdirectories

From Dev

Merge files with same name in different folders

From Dev

Is it possible to have two mailboxes(folders) with same name?

From Dev

Configure nginx to use files and folders with the same name

From Dev

Find files with same name in different folders

From Dev

JAVA: Iterate through multiple JSON arrays with same name until inner JSON array's child's condition is met - IBM Watson

From Dev

Iterate through folders and sub-folders/files and copy spreadsheet data to archive sheet

Related Related

  1. 1

    FOR loop to iterate through two folders

  2. 2

    Iterate Through Folders/Subfolders/Files in Google Drive

  3. 3

    Iterate through struct by variable name

  4. 4

    iterate through classes on same element

  5. 5

    iterate through classes on same element

  6. 6

    Batch File to Loop Through Folders and Copy Folder & Contents to Directory with Same Folder Name

  7. 7

    iterate through select dropdowns with same class name to find selection of specific option

  8. 8

    How to iterate through multiple child nodes with same name in a json response using C# and assert right content

  9. 9

    List folders with the same name in the same directory - Delphi

  10. 10

    Iterate through folders, then subfolders and print filenames with path to text file

  11. 11

    S3 Iterate through Bucket/Folders/Files

  12. 12

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

  13. 13

    Python iterate through df to create folders and copy files

  14. 14

    iterate through an enum type initialized with a string name?

  15. 15

    Batch command move png files to folders same name files and folders

  16. 16

    delete folders with the same name as the parent folders recursively in bash?

  17. 17

    Moving files with the same name to matching named folders

  18. 18

    Same name of two images in different folders of NSBundle

  19. 19

    Exclude/Include folders differently with the same name in sublime

  20. 20

    batch copy/move files to folders with same name

  21. 21

    Windows Phone Classes with same name but different folders

  22. 22

    filesyncprovider creates folders for documents with same name as document

  23. 23

    Delete content of folders with same name in different subdirectories

  24. 24

    Merge files with same name in different folders

  25. 25

    Is it possible to have two mailboxes(folders) with same name?

  26. 26

    Configure nginx to use files and folders with the same name

  27. 27

    Find files with same name in different folders

  28. 28

    JAVA: Iterate through multiple JSON arrays with same name until inner JSON array's child's condition is met - IBM Watson

  29. 29

    Iterate through folders and sub-folders/files and copy spreadsheet data to archive sheet

HotTag

Archive