顯示具有 batch script 標籤的文章。 顯示所有文章
顯示具有 batch script 標籤的文章。 顯示所有文章

星期五, 3月 08, 2013

[Windows batch] Delete file script when disk space is less than 1 TB

@setlocal enableextensions enabledelayedexpansion
@echo off

goto detect

:del_files
echo "
Hard Disk Space is less than 1TB , Now delete temp files..."    
Rem Customize your forfiles scripts body
Rem For example , under E:\backupdir directory ,
 delete files older than 55 days
forfiles.exe -p "E:\backupdir" -s -m file_name_* -D -55 -c "cmd /c del @FILE"
goto end

:detect
for /f "tokens=3" %%a in ('dir E:\') do (
    set bytesfree=%%a

)
set bytesfree=%bytesfree:,=%
echo The bytes free is : %bytesfree%
endlocal && set bytesfree=%bytesfree%

if %bytesfree% GTR 1099511627776 echo "Hard Disk Space is greater than 1TB ~! "
if %bytesfree% GTR 1099511627776 goto del_files
goto end


:end
echo good bye


星期一, 1月 02, 2012

Windows batch 如何ftp 自動撈檔案


一個在windows 詢問帳號密碼的範例:

@echo off
echo "Enter Username"
set /p UserName=
echo "Password"
set /p PassWord=
echo %UserName% %PassWord%






我改成如下:

autobackup.bat :


@echo off
set today=%date:~0,4%%date:~5,2%
echo %today%
cd D:\dbbackup
mkdir %today%
Rem 每次手動執行會建立  例如201201的資料夾
echo "Username is root"
Rem 已知ftp帳號為root
echo "Enter Password.."
set /p PassWord=
Rem 在這邊會問密碼
echo root> script.txt
echo %PassWord%>> script.txt
echo bin>> script.txt
echo lcd "D:\dbbackup\%today%">> script.txt
echo cd "/exp_dump">> script.txt
echo get "backup.log">> script.txt
echo quit>> script.txt
ftp -s:script.txt [server_ip]



LinkWithin-相關文件

Related Posts Plugin for WordPress, Blogger...