![]() |
Need help creating a file system
OS is XP pro.
How would I go about creating a file system of 2000 folders, each one named 0001-2000 respectivley? The idea is to be able to scan paperwork into each folder and to be able to instantly access whichever folder by typing in 1234 for example. Is there a way to create that many folders so named in a few clicks or would I have to manually create each one? Thanks. |
Create a batch (text) file in notepad called "create.bat" or something.
cd C:\ (or wherever you want to create them) md 0001 0002... 1999 2000 exit note - just separate the names with spaces. Note 2 - probably not a good idea to put 2000 folders at the root of C!! Run from a command prompt. I would use Excel (or similar) to create the list, using dragging, then use Word to copy the table and convert to text, replace paragraph marks with spaces, then paste into the batch file. Takes about 2-3 minutes. SD ps - you could do clever things with a data file and create the batch file with a variable for foldername and pass the datafile to it, but if you are only doing this once and have to create the text for the datafile anyway, it's quicker to just "hardcode" it. |
I tried this with half a million once ... admittedly under NT, I don't know how much the file system has improved since then for this sort of nonsense.
I rapidly came to the conclusion that it was vastly better to put all the files into SQL Server and use indexes rather than try to use the filing system. |
Classic database application.
You say scan paperwork which suggest no OCR and thus a need to store images of said documents. Database would have 1 table (entity) with 2000 records, each record would have 2 fields (attributes). One field would hold the record identification (e.g. 1234 - BUT make sure you set the datatype as text NOT integer), the other field would hold the image. MS Access can handle all this and has a fairly friendly GUI to assist in the setup. Using a Database means you get all the tools built in for backup, repair, replication, sorting, searching (only on record identification field if the docs are images, suggest a third field which contains text key words relating to doc contents - this would be searchable). Cron PM if you need more help. |
I loved DOS batch files!
Here is a crude way to do it (I'm sure there are better and neater batch constructs, but its too early on a Sunday morning for me...) -------------------------------------------------- cls @echo off REM makedirs.bat REM environmental variables used - intCounter REM initialize test value to be "true" SET intCounter=1 :while REM test condition (set to 10 here) IF %intCounter% GTR 10 (GOTO wend) REM procedure where condition is "true" md %intCounter% REM set new test value SET /a intCounter=intCounter+1 REM loop GOTO while :wend PAUSE ------------------------------------------------- :-) Mac |
Actually, thinking about it you could do it all in one command line (no need for environmental variables or batch files). 2000/XP only I'm afraid.
At the command line, in the directory where you want to create your folders, just type FOR /L %A IN (1,1,10) DO md %A This'll start the numbering at 1, increment by one each time and go on 'till 10 :-) Mac |
But it doesn't do what he wants.
|
Oh alright then....its very clumsy but it works (tested up to 2000 directories - quite quick, a few seconds) - 2000/XP only I'm afraid.
Now I'll have to redo it in old DOS and solicit some initial user input and dress it up and make it pretty and make an executable and........ ------------------------------------------------------- cls rem makedirs.bat set /A counter=0 set filename=0 rem counter is numeric and filename is a string :start set /A counter=%counter%+1 if %counter% LEQ 9999 set filename=%counter% if %counter% LEQ 999 set filename=0%counter% if %counter% LEQ 99 set filename=00%counter% if %counter% LEQ 9 set filename=000%counter% md %filename% rem Set your number of desired directories here (2000 in this case) if %counter% EQU 2000 goto end goto start :end ----------------------------------------------------------------------- ......I'd forgotten what a PITA this stuff is..... :-) Mac |
Thanks Mac, Could you please guide me on how to use that script? I've never tinkered with anything like that before. Cant test it at the moment as I'm at home and I'm not on XP. Something for the nightshift tonight.
Cheers. |
Using Windows Explorer, navigate to My Documents or wherever you want the folders to be. Right-click and choose New - Folder and make a new folder - name it something suitable like Files or whatever. Go into the new folder and right-click again, but choose New - Text Document and make a new text document - by default it'll be called New Text Document.txt.
Double-click on this new document and it'll open for editing. Copy and paste everything between the purple dotted lines in my post, save the document (File - Save) and close/exit the editor. Now you need to rename the New Text Document.txt - for simplicities sake call it makedirs.cmd - it MUST have either a .bat or a .cmd extension or it won't work -Windows may warn you about changing the extension but don't worry. Once you have done that you can double-click on makedirs and it'll go off and make your 2000 directories (takes about 6 seconds on my machine) and off you go. If this suits you then fine, but as others have pointed out this isn't the best way of handling a lot of data Cheers Mac |
Thanks! Will give it a whirl tonight.:)
|
Here's a nicer version where you can choose how many directories to create
Note that I haven't implemented proper error trapping in the input yet -------------------------------------------------- @echo off cls goto start rem makedirs.cmd rem Version 0.01.06 rem Creates multiple sequentially numbered subdirectories rem Copyright ajbc - ajbc{#at#}iafrica.com rem This utility starts from the directory that it finds itself in so rem put it in the directory where you want to create the new subdirectories :start set /P numdirs=How many directories do you want to create? rem get user input on number of directories to create echo. echo Please wait a moment while the directories are created set /A counter=0 set filename=0 rem counter is numeric (forced by /A) and filename is a string (default) :loop set /A counter=%counter%+1 if %counter% LEQ 9999 set filename=%counter% if %counter% LEQ 999 set filename=0%counter% if %counter% LEQ 99 set filename=00%counter% if %counter% LEQ 9 set filename=000%counter% md %filename% rem check if the counter has reached numdirs if %counter% EQU %numdirs% goto end rem exit when numdirs is reached goto loop :end rem end batch and exit ------------------------------------------------- Jeez I'm a sad bastard............... Mac :-) |
Originally Posted by Mac the Knife
(Post 5556225)
-------------------------------------------------
Jeez I'm a sad bastard............... Mac :-) Jim |
Class Act Mac!
Respect!
I do like the sub-routine to add leading zeroes! Very elegant! Hear it was a trifle warm in your part of the world today - maybe the heat enhances the grey matter? |
Well, here we are with error checking!
Why bother? Well, from my long ago days of DBase programming I'm still obsessive about sanitizing and checking input. Bad/unchecked input is how databases get corrupted or yield nonsensical answers, and its also how the bad guys are able to overflow buffers and inject code at runtime. DOS/Windows environmental variables are untyped and string or arithmetical manipulations are limited, difficult and rather idiosyncratic but at last now the routine won't stall or go into an endless loop or produce unexpected output. Rather appropriately I got my kitten to do fuzz testing by walking around on the keyboard and so far, so good - though I don't claim it is bulletproof. ----------------------------------------------------------------------- @echo off cls goto start rem makedirs.cmd rem Version 0.01.10 rem Creates multiple sequentially numbered subdirectories rem Copyright ajbc - ajbc{#at#}iafrica.com rem This utility starts from the directory that it finds itself in so rem put it in the directory where you want to create the new subdirectories rem environmental variables used are numdir, counter and filename :start set /P numdirs=How many directories do you want to create? rem get user input on number of directories to create :chk_input set /A number=%numdirs% if %number% LEQ 0 goto error1 rem Catches most non-numeric input like "Fred" or "hotpants" rem What is doesn't catch either causes an error2 or the batchfile simply exits if %number% GTR 9999 goto error2 rem Catches numbers > 9999 and invalid input that error1 misses :carry_on echo. echo Please wait a moment while the directories are created set /A counter=0 set filename=0 rem counter is numeric (forced by /A) and filename is a string (default) :loop set /A counter=%counter%+1 if %counter% LEQ 9999 set filename=%counter% if %counter% LEQ 999 set filename=0%counter% if %counter% LEQ 99 set filename=00%counter% if %counter% LEQ 9 set filename=000%counter% md %filename% rem check if the counter has reached numdirs if %counter% EQU %numdirs% goto end rem exit when numdirs is reached goto loop :error1 cls echo Invalid input! pause goto start :error2 cls echo Invalid input or exceeds 9999 subdirectory limit! pause goto start :end rem tidy up (remove variables used from environment) set numdirs= set counter= set filename= rem end batch and exit --------------------------------------------------------------------------- An old programmer's saying is that programs are never finished, merely abandoned! Thank you x213a for taking my remaining little grey cells for a run (gasp! gasp!) and thank you Feline (yes, its bloody hot in Cape Town today!) and jimtherev for your kind words! Mac |
Thanks Mac:ok:
Works perfectly - just what I needed! Now to start scanning... :) |
| All times are GMT. The time now is 10:15. |
Copyright © 2026 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.