Thursday, February 20, 2014

robocopy

Copy from C:\Dir1 to D:\Dir2

robocopy C:\Dir1  D:\Dir2 /mir

よく使うオプション:

/mir : mirror
/Z : copy files in restartable mode
/B : copy in backup mode

/XD file [file] : exclude files. Ex: /XF *.log *.iso
/XF dirs [dirs] :exclude directories. Ex: /XD C:\windows D:\temp

/LOG:file  : output status to LOG file (overwrite existing log)
/LOG+:file : output status to LOG file (append to existing log)

/NP : no progress
/NDL : no directory list  - don't log directory names


/R:n : number of retries on failed copies (default 1 mils)
/W:n wait time between retries  (default 30s)

/TEE: output status to console window as well as the log file

Friday, January 31, 2014

CMake 関連メモ

CMakeはなかなか気に入っています.しかし,説明資料などが少ない.忘れないためにここにメモを残すことにする

cmake-guiを使わずにコマンドライン,バッチorシェルから操作する.まず明確にする必要があるのは
  1. Source directory
  2. Build directory
  3. Generate project type:
    これはcmakeコマンドをタイプし生成できるプロジェクトタイプの一覧を確認する
  4. Tool chain
    ツールチェンの設定ファイルを使用する場合はそのパスを確認する
  5. CMake command line option
    cmake-guiで今まで手動で変更した設定をコマンドラインに落としておく必要がある.例:
    BUILD_OPTION_1 = ON
    BUILD_OPTION_2 = OFF ...
今までcmake-guiで操作したが,シェルスクリプトに置き換えてやりたい一例を下に示す

#!/bin/sh

SRC_DIR=...
BUILD_DIR=...
TOOL_CHAIN=...
GENERATOR_TYPE="Unix Makefiles"

cmake -D CMAKE_TOOL_CHAIN=$TOOL_CHAIN \
-G $GENERATOR_TYPE \
--build $BUILD_DIR \
-D BUILD_OPTION_1=ON \
-D BUILD_OPTION_2=OFF \
$SRC_DIR

ただし,上のコマンドをうまくいかないことがある(理由はまだ不明).スクリプトで -D オプションで定義したものがCMakeLists.txtファイル内で定義したものをオーバライドできない.

これを回避するために,自分専用日のPreloadのCmakefileを準備し,-C オプションでキャッシュの初期化を行ってからプロジェクトのCMakeListsを読みこませればよい.

Preloadスクリプトは通常のCMakeListsの書き方と全く同じ.ほとんどSET (FOO BAR ...)で書けばいい.


#!/bin/sh
cmake_minimum_required(VERSION 2.6)

set(MY_CMAKE_OPTION 1)
if(MY_CMAKE_OPTION EQUAL 1)
    set( OPT1  VALUE1  CACHE  BOOL "desc")
    set( OPT1  VALUE1  CACHE  BOOL "desc")  
else()
    ...
endif()


make VERBOSE=1 でmakeのコンパイル詳細Optionを表示

参考:
1. Cmake tutorial 1
2. Cmake tutorial 2
3. Cmake でオプションの設定方法

Wednesday, January 29, 2014

バッチファイル 定型文 処理 メモ

1.ファイルの存在チェック
if not exist "..." (
    echo Error: ...
) else (
    rem ...
)

2.DIRの存在チェック
dir "%DIR%"
if not errorlevel 0 (
    echo Error: ...
) else (
    rem ...
)

3.ユーザ入力
rem...

4.AAAAAAAAAAAAA

Thursday, January 23, 2014

Ubuntu, Lubuntu 12.04 with VirtualBox

Proxy設定for apt-get:はapt.conf.dの中に設定ファイル(例えばここでは80proxy)を追加

% export http_proxy="http://x.x.x.x:8080"
% export ftp_proxy="..."
% export https_proxy="..."

% sudo vim /etc/apt/apt.conf.d/80proxy
Acqurire::http::proxy "http://x.x.x.x:8080";
Acqurire::https::proxy "http://x.x.x.x:8080";
Acqurire::ftp::proxy "http://x.x.x.x:8080";

これでProxyを通してupdateできる 上記はapt-get用のプロキシの設定で,システムのプロキシ設定は/etc/environmentファイルを編集して追加する.
/etc/environment

http_proxy=http:// myproxy.server.com:8080/ 
https_proxy=http:// myproxy.server.com:8080/
ftp_proxy=http:// myproxy.server.com:8080/
no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"

VirtualBoxのネットワーク設定
(http://nwing.knowd.co.jp/yamazaki/index.php?q=node/169) このページはとてもわかりやすい
VirtualBoxの3Dアクセラレーションを有効にする方法

Sunday, December 22, 2013

自動でファイル名の先頭に日付時間情報を付加

ファイル名の先頭に日付を自動でRENAME

@echo off

rem --------------------------------------
rem Check parameters
rem --------------------------------------

if %1% == "" (
 call :usage
 pause
 exit
)

if "%2%" == "-no_ask" (
 set noask=1
) else (
 set noask=0
)

if NOT EXIST %1 (
 echo Error: file not found "%1%"
 pause
 exit
)

rem --------------------------------------
rem get file info
rem more info -> HELP CALL
rem --------------------------------------
set file_path=%~dp1

set file_name=%~nx1

rem --------------------------------------
rem get time
rem --------------------------------------
set date_tmp=%date:/=%
set time_tmp=%time: =0%
set yyyy=%date_tmp:~0,4%
set yy=%date_tmp:~2,2%
set mm=%date_tmp:~4,2%
set dd=%date_tmp:~6,2%
set hh=%time_tmp:~0,2%
set mi=%time_tmp:~3,2%
set ss=%time_tmp:~6,2%
rem set sss=%time_tmp:~9,2%
rem set time_stamp=%yyyy%_%mm%_%dd%_%hh%%mi%%ss%
set time_stamp=%yyyy%-%mm%-%dd%-%hh%%mi%%ss%
set file_new_name=%time_stamp%_%file_name%

rem ----------------------------------------
rem ask user
rem ----------------------------------------
echo Change: "%file_path%%file_name%" 
echo     To: %file_new_name%
if "%noask%" == "0" (
 set /p ask=Continue? [y/n]
) else (
 set ask=y
)

if "%ask%" == "y" (
 rename "%file_path%%file_name%"  "%file_new_name%" 
 echo Filename is changed.
 pause
 exit
)

:usage
echo Usage: Auto rename "file" to "YYYY_MM_DD_HHMISS_file"
goto EOF

rem ========================================
rem Finish.
rem ========================================

:EOF
echo Bye.