Code: Select all
@echo off
set foldername=D:\Prev_Machine\Pranab\Daimler\Xtech\Training\
for /f "usebackq tokens=*" %%a in (`dir /b/s/a:d %foldername%MigrationPoc`) do (
echo:%%~nxa
set file1=%foldername%MigrationPoc\%%~nxa
echo:%%~nxa
echo %file1%
for /f "usebackq tokens=*" %%a in (`dir /a-d /b %file1%` ) do (
echo:%%~na
)
echo:777
echo:%%~nxa
)
cd %foldername%
pause
I am getting output as which has problem:
Sch_A
Sch_A
D:\Prev_Machine\Pranab\Daimler\Xtech\Training\MigrationPoc\Sch_D --it is expected as D:\Prev_Machine\Pranab\Daimler\Xtech\Training\MigrationPoc\Sch_A
a1
b1
c1
d1
777
Sch_A
Sch_B
Sch_B
D:\Prev_Machine\Pranab\Daimler\Xtech\Training\MigrationPoc\Sch_D --it is expected as D:\Prev_Machine\Pranab\Daimler\Xtech\Training\MigrationPoc\Sch_B
a1
b1
c1
d1
777
Sch_B
Sch_C
Sch_C
D:\Prev_Machine\Pranab\Daimler\Xtech\Training\MigrationPoc\Sch_D --it is expected as D:\Prev_Machine\Pranab\Daimler\Xtech\Training\MigrationPoc\Sch_C
a1
b1
c1
d1
777
Sch_C
Sch_D
Sch_D
D:\Prev_Machine\Pranab\Daimler\Xtech\Training\MigrationPoc\Sch_D
a1
b1
c1
d1
777
Sch_D
Can any one rectify the code.