Skip to content

Instantly share code, notes, and snippets.

@doneykoo
Last active February 19, 2024 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doneykoo/28b415acd78ad11104d05d47674cdeb0 to your computer and use it in GitHub Desktop.
Save doneykoo/28b415acd78ad11104d05d47674cdeb0 to your computer and use it in GitHub Desktop.
traverse files recursively with certain extensions in windows folder, and unix2dos convert line endings to crlf
@echo off
setlocal
set "target_directory=%~1"
shift
set "extensions=%*"
if not defined target_directory (
goto ShowUsage
)
if not defined extensions (
goto ShowUsage
)
for %%e in (%extensions%) do (
for /R "%target_directory%" %%f in (*.%%e) do (
echo %%f
)
)
endlocal
exit /b 0
:ShowUsage
echo Usage: %0 [path_to_directory] [file_extension1] [file_extension2] ...
echo Usage: %0 C:\your_folder txt jpg png
exit /b 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment