I have to check whether a disk partition is ntfs or exFAT with cmd commands and assign the output to a variable.
If it is exFAT it will go to the formatting tag and will be formatted as NTFS but if it is NTFS it will go to the copyfile tag and some files will be copied to that partition.
I've been searching the internet for 3 days and I couldn't find it, maybe you can help or guide me on this issue.
Thank you in advance.
@echo off
call :NTFSLetter
for /f "tokens=5" %%a in ('fsutil fsinfo volumeinfo "%ntfsdrive%:"^|findstr /B "File System Name : "') do set DriveType=%%a
if "%DriveType%"=="exFAT" (
echo %DriveType%
GOTO :NTFSFormat
) ELSE (
GOTO :copyfile
)
:NTFSFormat
mycode...
pause
:copyfile
mycode...
pause
:NTFSLetter
set "ntfsdrive="
for %%a in (Z Y X W V U T S R Q P O N M L K J I H G F E D C) do cd %%a: 1>>nul 2>&1 & if errorlevel 1 set ntfsdrive=%%a
exit /b 0
Explanation:
I give the NTFS partition the drive letter automatically thanks to the :NTFSLetter tag.
So I have to use the %ntfsdrive% variable...
But this code structure is not working...