Batch script for making bulk empty/blank images. Included Inside! Great for Index mode

General discussion forum - for all that doesn't fit in any other category.
Post Reply
Prax
Posts: 3
Joined: Mon Sep 04, 2017 6:15 pm

Batch script for making bulk empty/blank images. Included Inside! Great for Index mode

Post by Prax » Sat Sep 09, 2017 4:21 pm

I created a simple batch program that will duplicate files on the fly. This is good for people using index mode primarily that wishes to create several blank/empty images quickly.

Just copy the contents below to notepad with the filename "duplicator.bat" and save (Also attached to this post.) Place a template HFE file in the same directory and just double click the batch file. The default is 100 copies of BLANK.HFE filename to DSKA0000.HFE ~ DSKA0099.HFE.
You can manually customize the defaults in the script or use command-line parameters to change the copy amount and/or template filename.
Such as "Duplicator.bat 20" to create 20 copies of BLANK.HFE or "Duplicator.bat 10 BLANKDOS.HFE" to create 10 copies of BLANKDOS.HFE

Code: Select all

@echo off
CLS
setlocal EnableDelayedExpansion


REM ----------------------------------------------
REM These are defaults. Allows the batch file to be run directly without command-line parameters.
REM ----------------------------------------------

set DefaultSource=BLANK.HFE
set DefaultCount=100

REM ----------------------------------------------
set Filename=DSKA
set Padding=0000
set Extension=HFE

echo  FILE DUPLICATOR v1.0 by Prax (HxC Floppy Emulator Forums) http://torlus.com/floppy/forum/

IF "%1"=="" (
     SET count=%DefaultCount%
) ELSE (
     SET count=%1
)

IF "%2"=="" (
     SET Source=%DefaultSource%
) ELSE (
     SET Source=%2
)

REM The count before subtracting 1
set "absoluteCount=%count%"

set /a count-=1

set "leadingZeros=%Padding%%count%"

echo -------------------------------------------------------------------------------------------
echo  SOURCE FILENAME..: %Source%
echo  NUMBER TO COPY...: %absoluteCount%
echo  FILE FORMAT......: %Filename%%Padding%.%Extension% ~ %Filename%!leadingZeros:~-4!.%Extension% 
echo -------------------------------------------------------------------------------------------
echo  SYNTAX: DUPLICATOR[.BAT] [1~9999 (Default: %DefaultCount%)] [SOURCE_FILENAME (Default: %DefaultSource%)]
echo  NOTE: Existing files will be skipped.
echo -------------------------------------------------------------------------------------------

SET /P AREYOUSURE=Are you sure (Y/[N])?
IF /I "%AREYOUSURE%" NEQ "Y" GOTO END

:START

for /L %%i in (0, 1, %count%) do (
     set "leadingZeros=%Padding%%%i"

     if exist %Filename%!leadingZeros:~-4!.%Extension% (
          echo [SKIP] %Filename%!leadingZeros:~-4!.%Extension% Exists.
     ) else (
          copy %Source% %Filename%!leadingZeros:~-4!.%Extension% >NUL
          echo [COPY] %Filename%!leadingZeros:~-4!.%Extension% Created.
     )
)
echo ------------------------------------------------------------
echo  DONE!
echo ------------------------------------------------------------
pause
exit

:END
echo ------------------------------------------------------------
echo  ABORTED
echo ------------------------------------------------------------
pause
exit
Attachments
duplicator.zip
(902 Bytes) Downloaded 6 times
file_duplicator.png
file_duplicator.png (10.71 KiB) Viewed 105 times

Post Reply