I have a code but I still have errors and I do not know how to solve it.
I want to make variables with the name of the file and match it to its size in this way f|archivo1.ext=tamaño
for this I have a temporary file where I include the name of the files and another temporary file where I include the size of the respective files.
setlocal
FOR /F "Delims=" %%A in ('TYPE name.tmp') DO (
FOR /F "Delims= " %%B in ('TYPE size.tmp') DO (
set "f|%%~A=%%~B"
)
)
Later in the same code I enter another file to see if there are similar files.
If the variable is not defined it means that the file is not in the temporary file name.txt
, but if the file is found, what I want to do is to see the sizes of the two files.
FOR /F "Delims=" %%A in ('DIR /B *.*^|Findstr /VE ".tmp"^|Findstr /VE ".ini"') DO (
if not defined f^|%%A (
echo %%A
) else (
setlocal Enabledelayedexpansion
echo.%%A "%%~zA" "!f|%%A!"
endlocal
)
)
I want that at the end it can be seen in the following way
documento1.txt "1948" "1948"
documento2.txt "120" "120"
And the problem is that it looks like this
documento1.txt "1948" "120"
documento2.txt "120" "120"
Only the size of the last file is taken.
I hope you can help me solve it