Common Windows Batch Processing

Source: Internet
Author: User

Toggle Execution Path
If you do not change the disk:
cd XXX
Change the disc:
cd/d xxx
Get Current date

It is important to use the date and time as the file name when writing Windows batch processing.

How do I get the date?
Format:%date%
Results: 2012-07-31

How to get the time?
Format:%time%
Results: 10:21:21.68

This is the date and time to get the system standard format, but sometimes we need to use the prescribed format, what to do?

Format:%date:~x,y% and%time:~x,y%
Description: X is the start position, Y is the number of characters acquired

For example, I want to get the full date and time,
Format:%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
Results: 20120731111039
But if the time is earlier than 10 o'clock, then only show the date does not show the time, such as: 20120731, how to solve it?
Format:%date:~0,4%%date:~5,2%%date:~8,2%0%time:~1,1%%time:~3,2%%time:~6,2%
Results: 20120731052539

This will achieve our goal, the success of the date and time.

Batch files open multiple folders at the same time

2006-09-23 00:05:36|  Category: PC Daily Applications | Tags: Batch processing | Report | font size Big small subscription



Open Notepad and enter the following:
(Assume that you want to open the C drive at the same time, the Flash folder under D, and the C-drive System32 folder)

Explorer.exe/n,c:
Explorer.exe/n,c:\windows

Explorer.exe/n,d:\flash

Delete a file folder

@echo off

REM If it is a disk character, it is best to add \ Match

Set Desc_path=e:\

REM only requires partial characters

Set File_str=rar

Set folder_str=hi6620

REM Control switch

Set search_file=1

Set Search_folder=1

Set Del_flag=1

REM temp file, backup record with no modification

Set File_log=file.log

Set Folder_log=folder.log

Set workspace=%cd%

REM only finds files

If%search_file%==1 (

CD/D%desc_path%

REM Search sub-directory, exclude folder

Dir/b/s/a-d | Find "%file_str%" >%workspace%\%file_log%

)

REM Only finds directories

If%search_folder%==1 (

CD/D%desc_path%

REM Objective: not to count files

Dir/b/s/a-a | Find "%folder_str%" >%workspace%\%folder_log%

)

REM is considered the introduction of input to determine if yes or no decides whether to delete, so more humane

Echo warning:%workspace%\%file_log% and%folder_log%, please check ...

Pause

CD/D%workspace%

If%del_flag%==1 (

If%search_file%==1 (

for/f%%i in (%workspace%\%file_log%) do (

If exist%%i del%%i

)

)

If%search_folder%==1 (

for/f%%i in (%workspace%\%folder_log%) do (

If exist%%i rd/s/q%%i

)

)

)

CD/D%workspace%

Pause

-----------Windows commands that automatically compile the wrapper

SET dotnetframeworkpath=c:/windows/microsoft.net/framework/v4.0.30319
SET Dotnetframeworkdrive=c:

REM if exist D:\WorkTemp\Release
del/f/s/q D:\WorkTemp\Release
Rd D:\WorkTemp\Release
echo----------------clean up and start building--------------------------


If not exist%ibasworkspace%\release\services\ MD%ibasworkspace%\release\services
Rem============================iispublish Engineering ===========================
CD%dotnetframeworkpath%
%dotnetframeworkdrive%
REM----------Create a directory for the corresponding module +svc file
MSBuild%ibassourcecode_tielong%\bizsys.containermanagement.service\bizsys.containermanagement.service.csproj/t : resolvereferences; compile/t:_wppcopywebapplication/p:configuration=release/p:_resolvereferencedependencies=true/p: Webprojectoutputdir=%ibasworkspace%\release\services\cmservice >>%ibasworkspace%/release/publishlog.txt

MSBuild%ibassourcecode_tielong%\bizsys.systemcenter.service\bizsys.systemcenter.service.csproj/t: Resolvereferences; compile/t:_wppcopywebapplication/p:configuration=release/p:_resolvereferencedependencies=true/p: Webprojectoutputdir=%ibasworkspace%\release\services\scservice >>%ibasworkspace%/release/publishlog.txt

@echo off


REM----------release Zip files in startup shell +xap file +bin file

copy/y%ibassourcecode_tielong%\bizsys.systemcenter.service\clientbin\ BSUi.SystemApplicationCenter.Silverlight.zip%ibasworkspace%\release\services\scservice\clientbin\ >% Ibasworkspace%/release/copyfilelog.txt
copy/y%ibassourcecode_tielong%\bizsys.systemcenter.service\clientbin\bsui.approvalprocess.silverlight.zip% Ibasworkspace%\release\services\scservice\clientbin\ >>%ibasworkspace%/release/copyfilelog.txt
copy/y%ibassourcecode_tielong%\bizsys.systemcenter.service\clientbin\bsui.businesssystemcenter.silverlight.xap %ibasworkspace%\release\services\scservice\clientbin\ >>%ibasworkspace%/release/copyfilelog.txt
copy/y%ibassourcecode_tielong%\bizsys.systemcenter.service\bin\*.*%ibasworkspace%\release\services\scservice\ Bin\ >>%ibasworkspace%/release/copyfilelog.txt


Echo waiting for clear the Webconfig files ... >>%ibasworkspace%/release/publishlog.txt

del/f/s/q D:\WorkTemp\Release\Services\Web.config
del/f/s/q d:\worktemp\release\services\scservice\clientbin\*. ClientConfig
del/f/s/q d:\worktemp\release\services\scservice\*.html
del/f/s/q d:\worktemp\release\services\scservice\*.aspx
del/f/s/q D:\worktemp\release\services\scservice\*.js
del/f/s/q D:\worktemp\release\services\scservice\*.bat
del/f/s/q D:\worktemp\release\services\scservice\*.config
del/q D:\WorkTemp\Release\Services\SCService\Handler
del/q D:\WorkTemp\Release\Services\SCService\DataService
Rd D:\WorkTemp\Release\Services\SCService\Handler
Rd D:\WorkTemp\Release\Services\SCService\DataService
del/f/s/q D:\worktemp\release\services\cmservice\*.xml
del/q D:\WorkTemp\Release\Services\CMService\DataService
rd/q D:\WorkTemp\Release\Services\CMService\DataService
REM copy/y%ibassourcecode_tielong%\bizsys.systemcenter.service\web.config%ibasworkspace%\release\services\ Scservice\web.config >>%ibasworkspace%/release/copyfilelog.txt


CD/D D:\WorkTemp\Release\Services
"%ibastools%\7zip\7z.exe" A-tzip services%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%.zip- R * *

Explorer.exe D:\WorkTemp\Release\
echo webconfig files have been cleared and the start Ptoject ' s config File has copied. >>%ibasworkspace%/release/publishlog.txt
Echo. & Pause

7z Compression Tool

Http://url.cn/bTu4W8

Common Windows Batch Processing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.