batch scripting
(in General on 2005/02/28)I answered this question for someone on a bulletin board that I frequent. The real answer is download perl/cygwin/etc but the person swore he didn’t have permission to do even that.
Filesystem layout is a toplevel directory, followed by 26 subdirs [a-z], each 1-letter subdir has a directory that represents a name.
Each name directory has some number of subdirectories (only 1-deep though) that has a number of documents whose filenames are unique for the username. He wants to move the files so that you have TOP/[a-z]/ANAME/files
e.g:
a/abe/abe1: file1.doc
a/abe/abe2: file2.doc file3.doc
a/alf/alf1: file1.doc file2.doc
for /F “usebackq” %%i IN (`dir /b /A:D`) do call :perletter %%i
goto :done:perletter
for /F “usebackq” %%k in (`dir %1 /b /A:D`) do call :pername %%k %1
goto :done:pername
cd %2%1
for /F “usebackq” %%i in (`dir /s /b /A:-D`) do echo move %%i .
for /F “usebackq” %%i in (`dir /s /b /A:D`) do echo rmdir %%i
cd ….:done
Of course, there are 2 echos in there to make this code harmless.
Comments Off

