A package for scrolling through all files with a predefined list or set of extensions and ignoring all other file types

I have the following windows-batch script to iterate over all the files in the current directory:

FOR %%F in (%CD%\*.*) DO (
    :: I am doing my process here
)

I know that I can iterate over a specific file type with *.ext, but I need to skip all the file types below and ignore all the other types that are also in a single loop FOR:

php
phtml
css
js
sql
xml

How can I achieve this by making at least small changes to my code?

I am not very good at batch scripting, so any help would be greatly appreciated.

+4
source share
1 answer

?

for %%I in (*.php *.phtml *.css *.js *.sql *.xml) do echo "%%I"

, , , :

for /F "delims=" %%I in ('dir /A-D /B *.php *.phtml *.css *.js *.sql *.xml 2^>nul') do echo "%%I"

DIR , , , - FOR - , FOR, DIR, , , , , , , , .

for /? dir /? , .

+1

Source: https://habr.com/ru/post/1682287/


All Articles