This is my first post and I hope someone can help me.
I'm fairly new to .bat files but I have a basic understanding of php and c++.
I need to write a batch file that will do the following: 1. Display all files including full filepath in the current folder. 2. Display length of the displayed files including the filepath for each individual file. 3. Maybe show how many files there are in total.
I've written this so far and it does Job #1 and #3 but I can't get it do display the string lenght.
@echo off
for /r . %%g in (*.*) do (
echo %%g
)
set cnt=0
for %%A in (*) do set /a cnt+=1
set /A cnt=cnt-1
echo Dateien im Verzeichnis = %cnt%
PAUSE
I found two other scripts that each identify lenght of a string or a path but I couldn't put them together with my first script.
Here the one for String Lenght:
@echo off
set myvar="some string"
rem compute the length of a string
set #=%myvar%
set length=0
:loop
if defined # (
rem shorten string by one character
set #=%#:~1%
rem increment the string count variable %length%
set /A length += 1
rem repeat until string is null
goto loop
)
echo myvar is %length% characters long!
PAUSE
And here a piece that will display the path length of the current folder:
@echo off
echo %cd%>"%TMP%\Temp.txt"
for %%l in ("%TMP%\Temp.txt") do set /a len=%%~zl
del "%TMP%\Temp.txt"
set /a len-=2
echo Path length = %len% chars.
PAUSE