'프로그래밍/Windows'에 해당되는 글 1건

  1. 2014.01.09 Useful commands used in Windows commands shell

Useful commands used in Windows commands shell


As Unix script language is actually quit powerful to do manipulate text, files/directories and so on, on Windows machine, there are many ways to do the same jobs. Here some useful examples which can be used in normal Windows .bat or .cmd and are also quit helpful in many option menus supported in Visual Studio. For example, before actual compilation of a project, someone may want to copy or create resources necessary to build binary to certain location or add a time stamp string to many source code files. For this purpose, we can add custom commands in Pre-build Event options of Visual Studio property setting window. 


So hope these examples show you a guidance on that. Again this information were taken from various link which I cannot remember correctly.



1. Searching files having specific extension in its file name in current folder


for %%f in (*.java *.cmd) do echo  %%f


2. Searching files with .java extension recursively  


dir /b /s /a-d | findstr /i ".java$


3. Find and delete files with certain name recursivly

 i) In batch file,

    for /f "usebackq" %%i in (`dir /s /b ^| find "Makefile"`) do echo %%i

 ii) In command line,

    for /f "usebackq" %i in (`dir /s /b ^| find "Makefile"`) do echo %i


 ** Note: replace "echo" with "del" to delete file instead of echoing file name.


4. Create array containing file names with full path located in specific folder. Note: In Windows there seems a limitation in assigning array from command line with use of pipe. So this is different trial to do that.

setlocal enabledelayedexpansion enableextensions

set LIST=

for %%x in (javaSourceFolder\*.java) do set LIST= %%x

set LIST=%LIST:~1%


5. Compiling all java files located at specific folder

---- Assuming %LIST% having file list with full path  ---

for %%f in (%LIST%) do (

 "$(JDK_ROOT)\bin\javac.exe" -d $(IntDir)$(JavaOutputDir) -classpath $(IntDir)$(JavaOutputDir) -classpath $(AndroidSdkApiDir)/android.jar %%f

)


6. QT

When you need to decide which build configuration among 32bit and 64bit, don't forget to keep using only one configuration. For example, if you develop qt application using Visual Studio C/C++ 20xx and want to use command prompt to build it, you need to choose build environment among 32bit, 64bit and 64bit_opengl. Once you pick one among them, DON'T FORGET to call proper bat file for Visual Studio compilation setup.


If you want 32bit QT application, run below command after opening QT command prompt

call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\vcvarsall.bat" x86


If you want 64bit QT application, run below command after opening QT command prompt

call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\vcvarsall.bat" x64


7. later...


Posted by kevino
,