Go Back  PPRuNe Forums > Misc. Forums > Computer/Internet Issues & Troubleshooting
Reload this Page >

Need help creating a file system

Wikiposts
Search
Computer/Internet Issues & Troubleshooting Anyone with questions about the terribly complex world of computers or the internet should try here. NOT FOR REPORTING ISSUES WITH PPRuNe FORUMS! Please use the subforum "PPRuNe Problems or Queries."

Need help creating a file system

Thread Tools
 
Search this Thread
 
Old 6th Mar 2010, 17:50
  #1 (permalink)  
Thread Starter
 
Join Date: Apr 2008
Location: November18
Age: 48
Posts: 258
Likes: 0
Received 0 Likes on 0 Posts
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.
x213a is offline  
Old 6th Mar 2010, 19:01
  #2 (permalink)  
Spoon PPRuNerist & Mad Inistrator
 
Join Date: Sep 2003
Location: Twickenham, home of rugby
Posts: 7,397
Received 265 Likes on 173 Posts
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.
Saab Dastard is offline  
Old 6th Mar 2010, 20:23
  #3 (permalink)  
 
Join Date: Nov 2000
Location: Cambridge, England, EU
Posts: 3,443
Likes: 0
Received 1 Like on 1 Post
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.
Gertrude the Wombat is offline  
Old 6th Mar 2010, 21:36
  #4 (permalink)  
 
Join Date: Apr 2000
Location: West Midlands, UK.
Age: 73
Posts: 294
Likes: 0
Received 0 Likes on 0 Posts
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.
Cron is offline  
Old 7th Mar 2010, 05:43
  #5 (permalink)  

Plastic PPRuNer
 
Join Date: Sep 2000
Location: Cape Town
Posts: 1,898
Received 0 Likes on 0 Posts
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
Mac the Knife is offline  
Old 7th Mar 2010, 06:03
  #6 (permalink)  

Plastic PPRuNer
 
Join Date: Sep 2000
Location: Cape Town
Posts: 1,898
Received 0 Likes on 0 Posts
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

Last edited by Mac the Knife; 7th Mar 2010 at 06:13.
Mac the Knife is offline  
Old 7th Mar 2010, 07:10
  #7 (permalink)  
Hippopotomonstrosesquipidelian title
 
Join Date: Oct 2006
Location: is everything
Posts: 1,826
Likes: 0
Received 0 Likes on 0 Posts
But it doesn't do what he wants.
Bushfiva is offline  
Old 7th Mar 2010, 12:53
  #8 (permalink)  

Plastic PPRuNer
 
Join Date: Sep 2000
Location: Cape Town
Posts: 1,898
Received 0 Likes on 0 Posts
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
Mac the Knife is offline  
Old 7th Mar 2010, 13:21
  #9 (permalink)  
Thread Starter
 
Join Date: Apr 2008
Location: November18
Age: 48
Posts: 258
Likes: 0
Received 0 Likes on 0 Posts
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.
x213a is offline  
Old 7th Mar 2010, 14:17
  #10 (permalink)  

Plastic PPRuNer
 
Join Date: Sep 2000
Location: Cape Town
Posts: 1,898
Received 0 Likes on 0 Posts
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
Mac the Knife is offline  
Old 7th Mar 2010, 14:42
  #11 (permalink)  
Thread Starter
 
Join Date: Apr 2008
Location: November18
Age: 48
Posts: 258
Likes: 0
Received 0 Likes on 0 Posts
Thanks! Will give it a whirl tonight.
x213a is offline  
Old 7th Mar 2010, 16:15
  #12 (permalink)  

Plastic PPRuNer
 
Join Date: Sep 2000
Location: Cape Town
Posts: 1,898
Received 0 Likes on 0 Posts
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 :-)
Mac the Knife is offline  
Old 7th Mar 2010, 16:40
  #13 (permalink)  
 
Join Date: Apr 2008
Location: Out in the sticks in DE56
Age: 85
Posts: 565
Received 7 Likes on 5 Posts
Originally Posted by Mac the Knife
-------------------------------------------------

Jeez I'm a sad bastard...............

Mac :-)
Norrabitofit, Mac! Time was that's what we were all doing! Congrats for remembering way back when.
Jim
jimtherev is offline  
Old 7th Mar 2010, 17:38
  #14 (permalink)  
 
Join Date: Sep 1999
Location: Deepest Dark Afrika
Posts: 175
Likes: 0
Received 0 Likes on 0 Posts
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?
Feline is offline  
Old 7th Mar 2010, 19:09
  #15 (permalink)  

Plastic PPRuNer
 
Join Date: Sep 2000
Location: Cape Town
Posts: 1,898
Received 0 Likes on 0 Posts
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

Last edited by Mac the Knife; 11th Mar 2010 at 11:30.
Mac the Knife is offline  
Old 7th Mar 2010, 20:35
  #16 (permalink)  
Thread Starter
 
Join Date: Apr 2008
Location: November18
Age: 48
Posts: 258
Likes: 0
Received 0 Likes on 0 Posts
Thanks Mac

Works perfectly - just what I needed!

Now to start scanning...

x213a is offline  

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Contact Us - Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service

Copyright © 2024 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.