'How to expand an string to a charractere in batch? [duplicate]

I have the file named: italo.jpeg

How to extract italo (before period) using:

set file=italo.jpeg
set prefix=%file:~[arguments]%

I've tried %file:~0,"."% but didn't work...



Solution 1:[1]

for /f "delims=." %%b in ("%file%") do set "prefix=%%b"

or, since this is a filename,

for %%b in ("%file%") do set "prefix=%%~nb"

Documentation : enter for /? at the prompt.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Magoo