
Re: Not work as add index on each ".sh" file
Hello wingcity,
first, it would be helpful to say which part doesn't work.
We can't help if you don't tell if the result isn't the one you expect or it fails with an error in line xyz or ...
Also it's a good idea to use the
CODE button, above the textbox to format your code.
Code:
@echo off
setlocal enabledelayedexpansion
set LocationDir=D:\Pong\
for /F %i IN ('dir /b/a-d/s *.sh') do (
set FileName=%~ni.sh
set DataFileName=!FileName!
(
rem //index information//@echo #########################################################################
echo # File Name:
echo # Calling sql:
echo # Type (update/query):
echo # Responsible Team:
echo # Last updated by:
echo # Last updated on (dd-mm-yyyy):
echo # Description:
echo #########################################################################
echo.
echo.
) > !LocationDir!!DataFileName!
rem for /f "tokens=*" %%k in ('type !DataFileName!') do (
rem set line=%%k
rem echo !line! >>!LocationDir!!DataFileName!
rem )
)
As you enable the delayed expansion, you should use it in your FOR-block, else your DataFileName expansion will not work.
Btw. It's not clear what you are trying to do with the second FOR/F loop.