@echo off
rem -------------------------------------------------------------------------
rem Batch file to execute a command on a set of files.
rem -------------------------------------------------------------------------
rem Revision History:
rem 6/5/1982 Fred Stluka
rem - Initial version for IBM VMS/CMS (FILELIST EXEC)
rem 10/12/1985 Fred Stluka
rem - Initial version for DEC VAX/VMS
rem 10/4/1988 Fred Stluka
rem - Initial version for Unix (find -exec, find -ok)
rem 12/2/1998 Fred Stluka
rem - Initial version for Windows NT
rem 2/3/2005 Fred Stluka
rem - Execute command via "call" in case it's a BAT file.
rem - Expand filenames to fully qualified paths via ~f.
rem - Notes explaining FOR command syntax.
rem $Log$
rem -------------------------------------------------------------------------
rem Turn echo back on if ECHO environment variable equals ON.
if not "%ECHO%"=="" echo %ECHO%
if "%1" == "" goto USAGE
if "%1" == "-?" goto USAGE
if "%1" == "/?" goto USAGE
if not "%OS%" == "Windows_NT" goto NOT_NT
rem Accumulate the DIR options and file specs (everything until "DO").
set DIR_PARAMS=
:GET_DIR_PARAMS
for %%i in (do DO dO Do) do if "%1"=="%%i" goto DO_FOUND
if "%1"=="" goto NO_DO_FOUND
set DIR_PARAMS=%DIR_PARAMS% %1
shift
goto GET_DIR_PARAMS
:DO_FOUND
shift
rem Run the command on the files.
rem
rem Notes:
rem - The /f switch causes FOR to parse each line in a file.
rem - The "Tokens=*" option causes an entire line of the file to be handled
rem at once. (Not required, since this is the default behavior.)
rem - Percent signs must be doubled on FOR loop variables inside BAT files.
rem - The apostrophes cause the DIR command to be evaluated to produce the
rem "file" to be parsed by /f.
rem - The ~f modifier expands the filename in %i to a fully qualified path.
rem - For more info, type: HELP FOR
rem
echo DIR parameters: %DIR_PARAMS%
echo Files to be processed:
for /f "Tokens=*" %%i in ('dir %DIR_PARAMS% /a-d /b') do echo "%%~fi"
rem Note: "echo." echoes a blank line. "echo ." would echo a dot.
echo.
echo Hit Ctrl-C to stop or any other key to continue:
:: pause > nul
for /f "Tokens=*" %%i in ('dir %DIR_PARAMS% /a-d /b') do call :EXECUTE %1 %2 %3 %4 %5 %6 %7 %8 "%%~fi"
goto EXIT
:EXECUTE
echo %1 %2 %3 %4 %5 %6 %7 %8 %9
rem
rem Note: The keyword "call" is needed here. Otherwise, if the first parameter
rem is the name of a BAT file, things get confused. The BAT file is not
rem executed, and the following error is reported:
rem The system cannot find the batch label specified - EXECUTE
rem
call %1 %2 %3 %4 %5 %6 %7 %8 %9
goto EXIT
:NOT_NT
echo Sorry. %0 only runs under Windows NT, 2000, XP, etc. Not 95, 98, ME.
goto EXIT
:NO_DO_FOUND
echo Invalid syntax. Must specify DO.
goto USAGE
:USAGE
echo %0 is a BAT file that executes the specified command on the specified
echo set of files. The files are specified as a set of parameters that would
echo cause the DIR command to select the right set of files.
echo Usage: %0 [dir_params...] DO command
echo Examples: %0 *.* DO type
echo Types all files in the current directory.
echo %0 DO type
echo Types all files in the current directory.
echo %0 /s DO type
echo Types all files in the current directory tree.
echo %0 *.exe DO start /wait /max
echo Runs all EXE files in the current directory, one at a
echo time, waiting for each to finish, in maximized windows.
echo %0 /s /aa c:\*.* DO xcopy /s /m /f
echo Incremental backup. Run with A:\ as the current
echo working directory. Copies all files with archive bit
echo set from the C drive to the current directory tree,
echo clearing the archive bits and echoing the names as
echo the files are copied.
echo %0 /s /a-r DO edit
echo Edit all files that are not readonly in the current
echo directory tree.
goto EXIT
:EXIT
Getting the Current TabItem when the Tab is not selected in WPF
-
[image: Banner]
This is a quick reminder to self on how to retrieve a TabItem from a WPF
TabControl *when the tab is not currently selected* because I ru...
1 month ago