Explanation of variable with ~ syntax

Hi
I got this batch script on the web for listing files with their sizes and there is one part I do not fully understand, so I was hoping someone could explain it to me
@echo off
c:
cd\
set /A Total=0, Cnt=0
for /F "tokens=*" %%A in ('dir %1 /S /B /A-D') do call :show "%%A"
goto :EOF
:show
set "Size= %~z1"
echo %~f1 %~t1 %Size:~-10% >> c:\test\files.txt
goto :eof
PAUSE

The part I don't understand is in the 3rd last line of the script:
%Size:~-10%

Is the whole variable everything between the two % characters?
I understand that the %Size is the Size variable which is set to the file size in the previous line, but I don't understand what the :~10% bit is doing - so please advise

%~z1 which Expands %1 to the size of the file.
%~f1 which Expands %1 to a fully qualified path name.
%~t1 which Expands %1 to the date/time of the file.
%Size:~-10% adds 10 charactors to the front of the Size variable. Like an align right if you will.

%Size:~-10% adds 10 charactors to the front of the Size variable. Like an align right if you will.

That is not correct. %Size:~-10% just starts ten positions from the right of %Size%.%A:~pos,len% results in the substring starting at (null-based) position pos, having length len. Negative positions will count from the right instead of the left.set A=1234567890echo %A:~1,1% echoes 2echo %A:~-2% echoes 90

To get a explanation, you don't need a link, just call set /?
for /?
in a DOS prompt and you will see all "substitution" variants.

0

Featured Post

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses. It simply renames the file(s) to match their create date. For example, if you took a picture today at 1:40pm and the …

Learn several ways to interact with files and get file information from the bash shell.
ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…