dos sort command

Microsoft Microsoft windows xp pro full...
April 20, 2010 at 04:52:20
Specs: Windows XP
I would like to produce a list from a DOS command line or Batch file - the output in following order:-
file name - drive\directory\subdirectories
file name - drive\directory\subdirectories

where the output is sorted on alpha of filename and directory includes complete file path and input includes all sub directories

See More: dos sort command

Report •

April 22, 2010 at 15:06:04
i think it will require a "temp/work" file, and i'm not sure the sort-order will be what you want, but this script will give it a go:
@echo off>tempfil & setlocal enabledelayedexpansion
set pad=
:: make the padding, might need to be bigger for real deep tree
:: use ast instead of spaces because of friggin "spaces-in-filenames" curse
for /L %%a in (1 1 20) do set pad=**********!pad!
for /f "tokens=*" %%a in ('dir /b /s') do (
set xx=%%~dpa
set yy=%%~na
:: this pads the path out so the subsequent sort will work correctly
set xx=!xx!!pad!
set xx=!xx:~0,200!
>> tempfil echo !xx!!yy!
sort /+200 tempfil > temp2
del tempfil
for /f "tokens=1-2 delims=*" do >> tempfil echo %%b *** %%a
::---- end
or, if you want the paths in an absolute column in the outputfile, use
the same padding technique but with spaces:
set space=            :
set xx=%%b!space!
set xx=!xx:~0,20!
>> tempfil echo !xx!%%a

Report •
Related Solutions

Ask Question