Batch File Request

January 18, 2010 at 09:23:34
Specs: Windows XP
If there is anyone who would be interested in creating a batch file for me that would be much appreciated. Here is what I need:
A batch file to loop through and create files and folders with the following naming convention:


At the first level there will be a folder named 00000000.
There will then be 512 sub-folders in that folder where the name is incremented by 1.
In each sub-folder there will be 512 files. These files can be empty txt files.
Once all of the files and folders are created the first level will need to be incemented by one then do the same thing again.
This first level will need to be created for a specified number of times. Thanks

See More: Batch File Request

Report •

January 18, 2010 at 13:44:53
The process is quite easy to work out, but it looks harmful like a nuclear device. So I want a detailed explanation of the purpose you request a so strange script for.

Report •

January 18, 2010 at 13:54:39
Thanks for the response. After further investigation I was able to get it written with a vb script. I needed it to be able to allow some software that I am working with the be able to delete some records. It is unable to do so when the physical file is missing.

Report •

January 18, 2010 at 14:09:11
Thank you for the explanation. I take caution before releasing potential malicious code. In this case the number of files and folders to be created steams up some questions. If you need any support, glad to help.

Report •

Related Solutions

January 18, 2010 at 14:38:53
(normally base zero goes to 511 for a 512 total...)
since i already did it, i'll jam it in here:

@echo off & setlocal enabledelayedexpansion
set /p aa=no. of bases to create:
set /a aa-=1
for /L %%i in (0 1 %aa%) do (
set xx=00000%%i
call :pad
set tt1=!xx!
for /L %%j in (0 1 512) do (
set xx=00000%%j
call :pad
set tt2=!xx!
for /L %%k in (0 1 512) do (
set xx=00000%%k
call :pad
set tt3=!xx! !tt1!\!tt2!\!tt3!.txt
>>build.bat @echo off>!tt3!.txt & echo xcopy !tt3!.txt !tt1!\!tt2!\ & del !tt3!.txt
echo examining output:
more build.bat
::remove colons in foll. line to cause creation of directories & files
(edit: add line:)
goto :eof

echo %xx%
set test=!xx:~8!
if "%test%"=="" set xx=0!xx! & goto :pad
echo %xx%

thanks, hope it helps even tho you already got it in vb.

Report •

January 18, 2010 at 16:18:55
Thanks nbrane, I was having dificulty figuring out how to do this with a batch file.

Report •

January 18, 2010 at 17:35:24
echo %xx%
set test=!xx:~8!
if "%test%"=="" set xx=0!xx! & goto :pad
echo %xx%

SET x=999
SET x=00000000%x%
SET x=%x:~-8%
ECHO %x%

Report •

January 18, 2010 at 20:26:52
ha! somehow i had a feeling it should have been easier...
it's f2p!
i haven't used the -n version of substring much, so i guess i tend to forget that it exists. maybe this oversight will remind me next time... LL

Report •

January 19, 2010 at 01:34:56
@echo off & setLocal EnableDELAYedeXpansion

pushd x:\00000000

for /L %%a in (0 1 512) do (
if %%a lss 1000 set D=00000%%a
if %%a lss 100  set D=000000%%a
if %%a lss 10   set D=0000000%%a
if not exist !D! md !D!
for /L %%i in (0 1 512) do (
if %%i lss 1000 set F=00000%%i
if %%i lss 100  set F=000000%%i
if %%i lss 10   set F=0000000%%i
> !D!\!F!.txt type nul

Helping others achieve escape felicity


Report •

Ask Question