Batch filesystem
From wikinotes
Read File
REM read file line-by-line set TEXT_T="C:\file.txt" for /f "eol= tokens=* delims= usebackq" %%i in (%TEXT_T%) do ( echo %%i )REM count lines in file FINDSTR /R /N "^.*$" tmpFile.txt | FIND /C ":"REM find all lines containing word findstr "word" "file.txt"REM Counts Instances of a character in a variable @echo off & setLocal EnableDelayedExpansion set str=C:\my\path\to\file set C=\ set N= :loop if !str:~0^,1! equ !C! ( set /a N+=1 ) if "!str:~1!" neq "" ( set str=!str:~1! goto :loop ) echo !N! pause
List Drives
fsutil fsinfo drives
Mounting Directory to DriveLetter
Mounting a Directory to a Drive letter is very useful if you are writing that is specific to a directory tree, and you want to work on it elsewhere. I wrote wp_testPadding.exe to copy a directory tree with empty files. If for instance I had recreated the Neverland_Pirates_3 folder from work, I could mount it to a drive letter, and all of my scripts would run.
subst W: D:\this\is\my\dir
FTP
echo USER BH_Design> ftpcmd.dat echo Bountydesign1>> ftpcmd.dat echo bin>> ftpcmd.dat echo put %1 "%location%/%filename%">> ftpcmd.dat echo close >> ftpcmd.dat echo bye >> ftpcmd.dat start /wait ftp -n -s:ftpcmd.dat "ftp.domsin.com" del ftpcmd.dat