1. List Dir structure in Tree style
tree /A "C:\TIBCOProjects" > C:\TIBCOProjects\DirTree.txt
2. Flush DNS changes in the network
ipconfig /flushdns
3. Net Stat find info and kill process
Ex.: Find process running on a specific port 8080
netstat -ano | find "8080"
or
netstat -ano | findstr 8080
----------------Sample--------------------
netstat -ano | find "4001"
sample outcome:
TCP 0.0.0.0:4001 0.0.0.0:0 LISTENING 1536
TCP 10.20.2.220:4001 10.20.10.108:1654 TIME_WAIT 0
TCP 10.20.2.220:4001 10.20.10.108:1696 TIME_WAIT 0
TCP 10.20.2.220:4001 10.20.10.108:1737 TIME_WAIT 0
TCP 10.20.2.220:4001 10.20.10.108:1783 TIME_WAIT 0
TCP 10.20.2.220:4001 10.20.10.108:1829 TIME_WAIT 0
----------------------------------------------
Kill the process running on the specific process id:
taskkill /F /PID <pid>
4. Sort then Unique the file recs:
Write the bat file with following content:
@echo off
goto :TopOfCode
=======================================================================
Author:
Warren Chen
Date: 2014.10.20
Useage:
SortAndUniqueFile.bat [SourceFile] [> OutputFile]
e.g.
SortAndUniqueFile.bat "c:\test case\input.txt" > "c:\test case\output.txt"
=======================================================================
:TopOfCode
setlocal disabledelayedexpansion
set "prev="
for /f "delims=" %%F in ('sort %1' ) do (
set "curr=%%F"
setlocal enabledelayedexpansion
if !prev! neq !curr! echo !curr!
endlocal
set "prev=%%F"
)
5. Move file from share location to local in Batch
Write bat file with following content:
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
rem ========== Configuration area ==========
set sourceDir=\\ulttib01\admin\test
set targetDir=C:\test\MoveFile\output
set fileType=*.xml
set batchSize=10
set fileCount=0
set sleepSec=1
set netDrive=s:
set leftFileCount=0
rem ========== Configuration area ==========
net use %netDrive% %sourceDir%
goto MoveFile
:MoveFile
for %%a in ("%netDrive%\%fileType%") do (
set /a fileCount+=1
rem echo the file is: %%a
if !fileCount! leq %batchSize% move "%%a" %targetDir%
)
set /a fileCount=0
:CountFile
set leftFileCount=0
for %%f in ("%netDrive%\%fileType%") do (
set /a leftFileCount+=1
)
echo File left: %leftFileCount%
goto CheckPoint
:CheckPoint
if !leftFileCount! gtr 1 (
echo sleep
ping 1.1.1.1 -n 1 -w 3000 > nul
echo finished sleep
goto MoveFile
) ELSE (
goto End
)
:CountFile1
FORFILES /S /M %netDrive%\*.xml /C "set /a fileCount+=1"
echo The file number is now: %fileCount%
:End
net use /del s:
ENDLOCAL
No comments:
Post a Comment