File Commands Dos Batch
Updated: 06/09/2012 10:22 AM

Combine multible files into 1
copy *.txt mytextfile.txt

Copy all directory names into a text file
dir /ad >list.txt

Copy all filenames into a text file
dir /a /-p /b /o:gen >list.txt

Copy all filenames with extra info into a text file
dir /a /-p /o:gen >list.txt

Compare 2 files
FC file.txt file2.txt

Search or Find a file
Dir c:\ /s /b | find "nade.txt"

See a tree structure of current directory
Tree > dirstructure.txt
Type dirstructure.txt

Copy dir to another place
@echo off

set LISTFOLDER=I:\Viborg\Final
set FILESPATH=I:\Viborg\Final\AlmeneArkiv
set DESTPATH=I:\Viborg\Final\CopiedTo

for /f "tokens=*" %%i in ('dir /b ^"%LISTFOLDER%\replacedir.txt^"') do (call :COPY_FILES "%LISTFOLDER%\%%i")

pause
exit

:COPY_FILES
for %%i in (%1) do set DEST=%%~ni
for /f "usebackq delims==" %%i in (%1) do xcopy /qv "%FILESPATH%\%%i" "%DESTPATH%\%%i\"


Directories to copy should be saved in replaceDir.txt as:
2
3
4
6


Url to this pages:
http://nade.dk/web/nade/site.nsf/FramesetHP?readform&wmain=files/File_Commands_Dos