Archive

Archive for the ‘Windows’ Category

DOS command for Deleting File by date

February 9, 2011 Comments off

Berikut adalah DOS script untuk delete file berdasarkan date modified. Kunci utama adalah merubah date menjadi Julian Date Format

ref: http://www.computing.net/answers/windows-xp/dos-command-for-deleting-by-date/170313.html

disempurnakan oleh sonypr@gmail.com

————-

@echo off
setlocal enabledelayedexpansion

rem –
rem Delete Files on Age in Days
rem –

rem File Age in Days to Delete
set FileAge=7

rem target directory
set sdir=d:\others

rem Get File list
pushd

dir %sdir%\*.* /a-d-h | find /v “(s)” > %sdir%\FileList.txt

rem Get Todays Day Number
for /F “tokens=1,2,3 delims= ” %%p in (“echo %date%”) do set tanggal=%%r
call :D ayNo %tanggal%
set Today=%DateNo%

rem Get File list and delete if over %FileAge% days old
for /f “skip=4 tokens=1-4,*” %%a in (%sdir%\FileList.txt) do (
call :D ayNo %%a
rem Calc File Age and delete if over %FileAge% days old
set /a CalcAge=%Today%-!DateNo!
if !CalcAge! GEQ %FileAge% (
rem echo %%e %%a !CalcAge! days old
del /p “%sdir%\%%e”
)
)
popd
rem del FileList.txt when ok
del %sdir%\FileList.txt
exit /b

rem Get Date Number
: DayNo %1
for /f “tokens=1,2,3 delims=/” %%a in (“%1″) do (
set /A mm=1%%a – 100
set /A dd=1%%b – 100
set yy=%%c
)
set /A DateNo=%dd%+((%mm%*306001)/10000)+((%yy%*1461)/4)
exit /b

Categories: scripting, Windows

Enable RDP connection to Citrix server for regular user

January 11, 2011 Comments off

sudah lama hal ini dilakukan, tetapi tidak ditulis sampai ketemu lagi permintaan ini.

 

Citrix by default akan melakukan prevent regular user remote desktop untuk melakukan RDP connection. Sometimes ada permintaan untuk mengenable hal ini. Caranya adalah

- Buka Citrix Connection Configuration (Metaframe sidebar – Citrix Connection Configuration)

- Klik ica-tcp

- di window edit connection – klik advance

- uncheck only lauch published application

 

Gambar tidak sempat diupload

Categories: Citrix, Windows

Processing multiple text file dengan batch command

November 5, 2010 Comments off

Script simple tapi cukup effective.

Idea: memisahkan text file yang mengandung kata-kata tertentu

for /R d:\test %%G in (*.tmp) do @call :parse %%G
goto :EOF
:parse
@set namafile=%1
@echo processing %namafile% …
@type %namafile% | find /I “giasi”
@goto hasil%errorlevel%
:hasil0
@copy %namafile% d:\test\med
@goto :EOF
:hasil1
@goto :EOF

For /R adalah looping job untuk processing command dari root directory sampai subdirectory terakhir

Ref:

- http://ss64.com/nt/for_r.html

- http://www.computing.net/answers/programming/batch-scripts-string-parsing/12733.html

Categories: scripting, Windows
Follow

Get every new post delivered to your Inbox.