2009년 5월 11일 월요일

Daily folder share rotating batch file

Sharing folder rotating batch file without change share name.
===================================================

What it does
------------
1. Make a folder with name of current date
2. share the folder with a share name, with open priviledge.

Usage
-----
- Copy following batch file contents, and paste to a text batch file such as newsharefoler.bat
- Configure to change the share name and folder name : Share name "OPEN", Folder name "OPEN_date" in contents.
Each occurs twice, you can change as you want.
- Place batch in a folder that will have sharing subfolder. Just click batch file to make today share folder.

Note that other language OS than english user must change 'current' to OS's current meaning, which appears after type 'date' at cmd prompt.

Contents
--------
@echo off
REM daily folder share rotating batch file
net share OPEN /delete
date < nul > do.bat
echo . >> do.bat
echo mkdir OPEN_%%2 > current.bat
echo cd OPEN_%%2 >> current.bat
echo set cwd="%%cd%%" >> current.bat
echo cd .. >> current.bat
echo net share OPEN=%%cwd%% >> current.bat
echo cacls %%cwd%% /g everyone:F >> current.bat
echo y|call do.bat
del do.bat
del current.bat



날짜별로 공유 폴더 변경하면서 공유명은 변경하지 않기
==============================================

무슨 작업을 하나?
-----------------
1. 현재 날짜가 이름에 들어있는 폴더를 만든다.
2. 만들어진 폴더를 공유한니다.


사용법
------
공유명과 폴더명을 자신이 원하는 것으로 바꾸고, 공유폴더를 만들기 원하는 폴더에서 실행시킨다. 기본 공유명은 OPEN 이고, 폴더명은 "OPEN_날짜"인데, 배치파일내에서 원하는 이름으로 변경한다. 날짜 부분인 %%2는 변경하지 말 것. 공유폴더를 만들 폴더에 배치파일을 저장하고, 배치파일을 클릭하면, 오늘날짜의 공유 폴더가 만들어진다.

아래 배치파일 내용에서 @echo off 부터 del 현재.bat까지의 내용을 복사해서 newsharefoler.bat와 같은 배치 파일로 저장한다.


배치파일 내용
-------------
@echo off
REM 매일 공유폴더 변경 배치파일
net share OPEN /delete
date < nul > do.bat
echo . >> do.bat
echo mkdir OPEN_%%2 > 현재.bat
echo cd OPEN_%%2 >> 현재.bat
echo set cwd="%%cd%%" >> 현재.bat
echo cd .. >> 현재.bat
echo net share OPEN=%%cwd%% >> 현재.bat
echo cacls %%cwd%% /g everyone:F >> 현재.bat
echo y|call do.bat
del do.bat
del 현재.bat


배치파일 설명
-------------
@echo off
REM daily folder share rotating batch file
REM 매일 공유폴더 변경 배치파일
net share OPEN /delete : 기존 공유명을 삭제
date <> do.bat : '현재 날짜: 2009-05-12'가 적힌 배치 do.bat 생성
echo . >> do.bat : 새로운 날짜 입력 취소를 위한 엔터 입력
echo mkdir OPEN_%%2 > 현재.bat : 두번째 명령행 인수로 폴더이름을 만드는 배치 현재.bat
echo cd OPEN_%%2 >> 현재.bat : 만들어진 폴더로 이동
echo set cwd="%%cd%%" >> 현재.bat : 현재 폴더 위치 변수 cd를 변수명 cwd로 저장
echo cd .. >> 현재.bat
echo net share OPEN=%%cwd%% >> 현재.bat : 만들어진 폴더 공유
echo cacls %%cwd%% /g everyone:F >> 현재.bat : 만들어진 폴더 권한 변경 (모두 쓰기 가능)
echo y|call do.bat : 배치파일 실행, do에서 현재.bat 실행
del do.bat : 사용후 배치 삭제
del 현재.bat : 사용후 배치 삭제

댓글 없음:

댓글 쓰기