Posted by member 99 on 2004-08-23 00:09:04 link
Ignore my post if you use Win9x.
You and your VB mumbo-jumbo! This is guaranteed to delete all of your files while trying to sort them:
Seriously though, that is an excellent idea. Note that my batch file will not sort subdirectories. (say, anybody up for a mzscript version? ;)
You and your VB mumbo-jumbo! This is guaranteed to delete all of your files while trying to sort them:
@echo off
setlocal
if errorlevel 1 goto noluck
:: strip quotes
set ROOT=%1.
if %ROOT:~0,1%.%ROOT:~0,1%=="." set ROOT=%ROOT:~1,-1%
set ROOT=%ROOT:~0,-1%
:: ask for the root if we weren't told
if "%ROOT%"=="" (
set /P ROOT=Enter root folder or drag^&drop here:
)
:: strip quotes
set ROOT=%ROOT%.
if %ROOT:~0,1%.%ROOT:~0,1%=="." set ROOT=%ROOT:~1,-1%
set ROOT=%ROOT:~0,-1%
:: quit if they really aren't talking
if "%ROOT%"=="" goto :eof
pushd "%ROOT%"
if errorlevel 1 goto baddir
:: do the stuff
for /D %%d in (*) do call :move %%d
for %%d in (*) do call :move %%d
popd
goto :eof
:baddir
echo "%ROOT%"
goto :eof
:move
set WHAT=%*
:: skip 1-char long names
if "%WHAT:~1,1%"=="" goto :eof
:: make the section if it doesn't exist
if not exist "%WHAT:~0,1%" md "%WHAT:~0,1%"
:: brush your teeth
move "%WHAT%" "%WHAT:~0,1%\%WHAT%" > NUL
goto :eof
:noluck
echo Sorry, your OS isn't special enough.
Let me know if it doesn't work.setlocal
if errorlevel 1 goto noluck
:: strip quotes
set ROOT=%1.
if %ROOT:~0,1%.%ROOT:~0,1%=="." set ROOT=%ROOT:~1,-1%
set ROOT=%ROOT:~0,-1%
:: ask for the root if we weren't told
if "%ROOT%"=="" (
set /P ROOT=Enter root folder or drag^&drop here:
)
:: strip quotes
set ROOT=%ROOT%.
if %ROOT:~0,1%.%ROOT:~0,1%=="." set ROOT=%ROOT:~1,-1%
set ROOT=%ROOT:~0,-1%
:: quit if they really aren't talking
if "%ROOT%"=="" goto :eof
pushd "%ROOT%"
if errorlevel 1 goto baddir
:: do the stuff
for /D %%d in (*) do call :move %%d
for %%d in (*) do call :move %%d
popd
goto :eof
:baddir
echo "%ROOT%"
goto :eof
:move
set WHAT=%*
:: skip 1-char long names
if "%WHAT:~1,1%"=="" goto :eof
:: make the section if it doesn't exist
if not exist "%WHAT:~0,1%" md "%WHAT:~0,1%"
:: brush your teeth
move "%WHAT%" "%WHAT:~0,1%\%WHAT%" > NUL
goto :eof
:noluck
echo Sorry, your OS isn't special enough.
Seriously though, that is an excellent idea. Note that my batch file will not sort subdirectories. (say, anybody up for a mzscript version? ;)