问题描述:

I am facing issue in writing the matched file name ignoring first 7 characters in folders

@echo off

for %%i in ( "C:\*" ) do if exist "C:\temp\%%~nxi" (

REM Set FileExistsName

set "FileExistsName=%%~nxi"

REM Set Skip 7 first characteres

set "FileMatched=!FileExistsName:~7!"

if "%FileMatched%" NEQ [] (

echo !FileMatched! >> C:\temp\fileoutput.txt

)

)

echo Script Completed

pause

exit

The script works as expected however it's not displaying matched output. Could someone advise.

网友答案:
if "%FileMatched%" NEQ [] (

This will never be true (due to several reasons).

Probably you want to use

if "!FileMatched!" NEQ "" (
相关阅读:
Top