The udf1.02 label is noted as a "VolumeIdentifier" in your linked pdf-file.balubeto wrote:At this point, I found this document http://www.osta.org/specs/pdf/udf102.pdf , but I found nothing on the volume label validity.
Since it seems to me impossible that there is nothing on the topic, you may look at this pdf as you are more experienced than me?
But there is only the information that its maximum length is 32 characters (as we knew before).
Because of that i assume it has the same restrictions than the previous CD file systems.
So the following characters should be the only allowed ones (and used 0-32 times):
'_', '0', ... '9', 'A', ..., 'Z'
Under that assumption, the following may help you:
Code: Select all
@echo off
setlocal enableExtensions disableDelayedExpansion
call :setValidLabel "label" "%~1"
echo label: "%label%"
endlocal
endlocal
goto :eof
:setValidLabel
:: %~1 variable to set
:: %~2 default value
setlocal disableDelayedExpansion
set "label=%~2"
set "first=1"
:validateLabel
set "invalid="
setlocal enableDelayedExpansion
set "label= !label!"
if not "!label:~33!" == "" set "invalid=More than 32 characters are not allowed for the volume label."
for /F "delims=_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" %%a in ("!label!") do (
setlocal disableDelayedExpansion
if not "%%~a" == " " (
endlocal
set "invalid=The only allowed characters are '_', '0', ... '9', 'A', ..., 'Z'."
) else endlocal
)
endlocal & set "invalid=%invalid%"
if defined invalid (
if not defined first echo(%invalid%
set "first="
set "label="
set /p "label=Please enter a valid volume label (UDF 1.02 volume identifier): "
goto :validateLabel
)
endlocal & set "%~1=%label%"
goto :eof
penpen