1

I just upgraded Windows 10. But the batch file I wrote not works completely. Same coding was working with Windows 7. That's the piece of code.

:BASLA
SETLOCAL ENABLEDELAYEDEXPANSION

set "s=DIR D:\Diziler /S /Q ^|FIND /i "Administrators" ^|findstr /m /i "HDTV" ^|findstr /m /i "\.mkv$""
for /f "Tokens=5,6*" %%f in ('%s%') do (
    set FULLNAME=%%f
    set ENDTEXT=!FULLNAME:*0p=!
    call set TRIMMEDNAME=%%FULLNAME:!ENDTEXT!=%%

for /r D:\Diziler\ %%g in (*) do echo %%~nxg >> %tmp%\altyazi.txt 

>nul findstr /c:"!FULLNAME:~0,-4!.srt" %tmp%\altyazi.txt  && (
>>%tmp%\list.txt echo !TRIMMEDNAME!*
) || (
>>%tmp%\list.txt echo !TRIMMEDNAME!
)
)
)

First part is working as usual. altyazi.txt gives the right output. But when it comes the list.txt all the outputs are Echo is off. I have never seen something like this. Works with 7 but doesn't work with 10.

Rıdvan Çetin
  • 183
  • 5
  • 16
  • There's apparently an unneeded closing `)` at the end, what happens if you remove it? – wOxxOm Aug 04 '15 at 14:15
  • I just noticed it but nothing happens when I remove it. – Rıdvan Çetin Aug 04 '15 at 14:17
  • Obviously `TRIMMEDNAME` is empty, so you should check what content is in `FULLNAME` and `ENDTEXT`. Then you should change your SET syntax to `set "FULLNAME=%%f"` and `set "ENDTEXT=!FULLNAME:*0p=!"` to avoid problems with trailing spaces. Probably the output of `DIR /Q` has changed – jeb Aug 04 '15 at 14:28
  • You were right. FULLNAME shows "Administrator" as data. But it shouldn't. How can I make it right? – Rıdvan Çetin Aug 04 '15 at 14:34
  • It would be a good idea to compare the output of DIR /Q for both systems and post it here, but please only for one file – jeb Aug 04 '15 at 14:36
  • 1
    Your comment gave me an idea. I think that Windows 10 and Windows 7 are giving different columns when DIR listing. So I changed tokens 5,6 to 6,7 problem solved! – Rıdvan Çetin Aug 04 '15 at 14:37
  • 1
    Since you found the solution of your problem, please post it as an answer and accept it, so the question does not remain open in the SO database... – aschipfl Oct 06 '15 at 23:40

1 Answers1

0

Windows 10 and Windows 7 are giving different columns when DIR listing. Changing the tokens would solve the problem.

Rıdvan Çetin
  • 183
  • 5
  • 16