batch for forlders synchronization

 synfolders.bat@echo onrem Save the current dir, [d] is disk letter, [p] is path namepushd %~dp0rem Change...

 synfolders.bat

@echo on

rem Save the current dir, [d] is disk letter, [p] is path name
pushd %~dp0

rem Change into my work dir
e:
cd \My Documents\My Company\ÈÕ¿¯\Code\pub

rem Coping my files to the public server
xcopy * l:\pub /s/e/y

rem Create the new dir with current system date in the pravite dir
rem [%DATE:~-10%] is get the last 10 ascii from the system date
md l:\zhangy\pub\%DATE:~-10%

rem Coping my file to the new dir in the pravite dir
xcopy * l:\zhangy\pub\%DATE:~-10% /s/e/y
xcopy * l:\zhangy\pub\whole /s/e/y

rem Resume the old dir
popd

@echo off 

batch of operation under DOS

How to get a list of files name without path, size and datetime.rem '/b' is short...

How to get a list of files name without path, size and datetime.

rem '/b' is short list, '/on' is sort by name, '/a-d' is list all except dir.
dir /b/on/a-d/s > list.txt

How to add string to each of a batch of files name. 

rem add double '@' into the start of each file name with full path and extension.
FOR /R %I IN (*.fnc *.prc *.sql *.bdy *.spc) DO echo @@%~fnxI

for command reference

dos> for /? (part of)

 %~I         - expands %I removing any surrounding quotes (")
 %~fI        - expands %I to a fully qualified path name
 %~dI        - expands %I to a drive letter only
 %~pI        - expands %I to a path only
 %~nI        - expands %I to a file name only
 %~xI        - expands %I to a file extension only

How to rename a bench of files name

FOR /R %I IN (*.*) DO ren *.* *.bak

 

Execute batch file before windows shutdown

click start -> run.enter gpedit.msc, then click OK.find the path of  Computer Configuration -> Windows Settings...

click start -> run.

enter gpedit.msc, then click OK.

find the path of 

Computer Configuration -> Windows Settings -> Scripts(Startup/Shutdown)

then add the path of batch files which you want to be executed before shutdown to the Shutdown item. 

Reference 

 

mail.png


标签订阅|Tag Subscription

If you use an RSS reader, you can subscribe to a feed of all future entries tagged 'batch'. [What is this?]

Subscribe to feed Subscribe to feed

最近更新|Recent Entries

不定期更新|Handy Entries

其它标签|Other Tags

分类栏目|Categories

按月归档|By Month

2008
11
10
07
05
04
03
02
01
2007
12
10
07
06
05
04
03
02
01
2006
12
11
10
09
08
07
06
05
04
03
02
01
2005
11
10
09
08
07
04
03
2004
12
11
10
09
08
07
06
05
04
03
02
01
2003
12
10
09
08
06
2002
09
08
04
03
02
2001
12
09
07
06
05

站内链接|Site Links

Powered by
Movable Type 3.34