dancer79uk
2023-11-12 22:54:02 UTC
I'm trying to get a percentage complete function for copying the Windows 98 setup files to hard disk. For this, I'm using DOS from a Windows 98 boot disk. I'd like to be able to count the number of files in the WIN98 folder on the Windows 98 CD and put this into a variable. I'm using this but it won't work:
dir /a:-d "%cdrom%\WIN98" | find /c ":\" > tempFile.txt
SET /p FilesCount=<tempFile.txt
ECHO There are %FilesCount% in the folder.
It doesn't display the FilesCount variable. The tempfile.txt file does have the number in it, in this case 102, but it won't display it (it's just a blank). Is it because it's for a later version of Windows? I'd like to get this for a percentage complete function that is coded like this (this was found after a StartPage search and looks like what I'm after):
-------------------------------------------------
@echo off&color a
setlocal enabledelayedexpansion
cd /
mkdir ZZZDestination
set startdir="C:\ZZZSource\Depth1\Depth2\the files"
set enddir="C:\ZZZDestination\"
echo.
echo Press any key to continue
PAUSE>nul
for /f "tokens=1,2,3,4,5" %%a in ('dir /s %startdir%^|findstr bytes') do if /i not "%%e"=="free" set qtyfiles=%%a
set filecount=0
for /f "tokens=*" %%a in ('dir /a-d-h-s /s /b %startdir%') do (
xcopy /z /q /s /e /y "%%a" "%enddir%\%%~pa\*.*" >nul
set /a filecount=!filecount!+1
set /a percentage=!filecount!*100 / !qtyfiles!
cls
echo.
echo Copying files, PLEASE DO NOT CLOSE THIS WINDOW
echo ======================================================
echo Please wait for copying: !percentage!%% Completed
echo ======================================================
)
echo.
echo DONE, please press any key to exit..
PAUSE>nul
----------------------------------------------------------------
I believe that this code will only work in later versions of Windows. I would be using COPY and not XCOPY to copy the Windows 98 setup files to hard disk (although XCOPY could be used)
I'm not a programmer and can barely understand the above batch code but would like to be to get it to work in a Windows 98 DOS environment. I don't think I need the first part for %qtyfiles% as I would already have this as %FilesCount%
Thanks in advance to anyone that might be able to help.
dir /a:-d "%cdrom%\WIN98" | find /c ":\" > tempFile.txt
SET /p FilesCount=<tempFile.txt
ECHO There are %FilesCount% in the folder.
It doesn't display the FilesCount variable. The tempfile.txt file does have the number in it, in this case 102, but it won't display it (it's just a blank). Is it because it's for a later version of Windows? I'd like to get this for a percentage complete function that is coded like this (this was found after a StartPage search and looks like what I'm after):
-------------------------------------------------
@echo off&color a
setlocal enabledelayedexpansion
cd /
mkdir ZZZDestination
set startdir="C:\ZZZSource\Depth1\Depth2\the files"
set enddir="C:\ZZZDestination\"
echo.
echo Press any key to continue
PAUSE>nul
for /f "tokens=1,2,3,4,5" %%a in ('dir /s %startdir%^|findstr bytes') do if /i not "%%e"=="free" set qtyfiles=%%a
set filecount=0
for /f "tokens=*" %%a in ('dir /a-d-h-s /s /b %startdir%') do (
xcopy /z /q /s /e /y "%%a" "%enddir%\%%~pa\*.*" >nul
set /a filecount=!filecount!+1
set /a percentage=!filecount!*100 / !qtyfiles!
cls
echo.
echo Copying files, PLEASE DO NOT CLOSE THIS WINDOW
echo ======================================================
echo Please wait for copying: !percentage!%% Completed
echo ======================================================
)
echo.
echo DONE, please press any key to exit..
PAUSE>nul
----------------------------------------------------------------
I believe that this code will only work in later versions of Windows. I would be using COPY and not XCOPY to copy the Windows 98 setup files to hard disk (although XCOPY could be used)
I'm not a programmer and can barely understand the above batch code but would like to be to get it to work in a Windows 98 DOS environment. I don't think I need the first part for %qtyfiles% as I would already have this as %FilesCount%
Thanks in advance to anyone that might be able to help.