There is a batch file for outputting all files with the requested extension and name, but my error displays only the first file, and when output, it writes a syntax error

@echo off echo Output file name and characteristics if "%1"=="" ( echo Do not specify the 1st parameter echo Input /? to output help pause goto :EOF ) if "%1"=="/?" ( echo Output file name and characteristics echo 1st parameter - folder name echo 2nd parameter - file type echo Types: echo -text for *.txt echo -command for *.bat echo -all for *.* pause goto exit ) if not exist %1 ( echo Folder is not exist pause goto exit ) if not "%1"=="." ( pushd %1 ) if "%2"=="" ( echo Do not specify the 2nd parameter set /p nam=Input file name: set /p ext=Input file extension: ) else (goto run) if not exist "*.%ext%" ( echo There are not *.%ext% files in this folder pause goto exit ) else (goto user_type) :run if "%2"=="text" ( for %%I in (*.txt) do call :attrib1 "%%I" .txt pause goto exit ) if "%2"=="command" ( for %%I in (*.bat) do call :attrib1 "%%I" .bat pause goto exit ) if "%2"=="all" ( for %%I in ("*.*") do call :attrib1 "%%I" %%~xI pause goto exit ) :user_type for %%I in (%nam%.%ext%) do call :attrib1 "%%I" .%ext% pause goto exit pause goto :exit :attrib1 echo Output file name and characteristics for file %1 attrib %1 echo End exit /b :exit if not "%1"=="." (cd ../) 

Console

  • one
    It seems to me that the problem is that you use the for parser to parse the values ​​obtained from the text file, and you need to process the file (its ATTRIBUTES), and not its contents. For this there is a built-in utility FORFILES - Daemon-5
  • @ Daemon-5 Can you give an example please - Alexander
  • one
    forfiles / p "C: \ Users \ Aleks \ Documents" / m * .txt / c "cmd / c attrib @file" or in your case forfiles / p "% 1" / m *.% 2 / c "cmd / c attrib @file " - Daemon-5 4:52 pm

0