2014年6月11日 星期三

批次檔自動化 壓縮 解壓縮 (7z command line)

首先,需要先下載7z command
https://dl.dropboxusercontent.com/u/46826128/7z%20command%20line.7z
===========================================================
7z 壓縮 加入密碼

@echo off
".\7-Zip\7z.exe" a -t7z -r -y -p123 -mhe 123.7z .\123.txt

pause
===========================================================
7z 解壓縮 輸入密碼

@echo off
echo.
echo 請輸入密碼
".\7-Zip\7z.exe" e 123.7z -y -o.\* | find "Error" > nul
if %errorlevel%==0 echo 發生錯誤

pause
===========================================================
參考:


7-Zip Command line 使用者介紹

http://puremonkey2010.blogspot.tw/2011/01/windows-7-zip-command-line.html

7-Zip Command line
http://www.dotnetperls.com/7-zip-examples

Command Line Syntax
http://sevenzip.sourceforge.jp/chm/cmdline/syntax.htm
===========================================================

(綠色皮) 最新C程式語言, 施威銘研究室 著, 旗標 第十一章 '參考' 答案

==============================================
/* 程式檔名:test_11-53-1.c*/
/* 程式目的:螢幕輸出字串"Hello World"*/
/* 程式設計:蘇彥儒*/
/* 完成日期:20140527*/
#include <stdio.h>

int main(void)
{
    char name[]="Hello Word";
    printf("%s \n",name);
    system("pause");
    return 0;
}
==============================================
/* 程式檔名:test_11-53-2.c*/
/* 程式目的:"Hello World"反過來輸出*/
/* 程式設計:蘇彥儒*/
/* 完成日期:20140527*/
#include <stdio.h>

int main(void)
{
    char name[]="Hello World!!";
    int i;
    printf("%s \n",name);
    for(i=strlen(name)-1;i>=0;i--)
    {
printf("%c",name[i]);
    }
    system("pause");
    return 0;
}
==============================================
/* 程式檔名:test_11-53-3.c*/
/* 程式目的:"Hello World"將字串複製*/
/* 程式設計:蘇彥儒*/
/* 完成日期:20140527*/
#include <stdio.h>
#include <string.h>
int main(void)
{
  char str1[]="Hello";
  char str2[]="World";
  printf("第 1 個 字串 %s \n",str1);
  printf("第 2 個 字串 %s \n",str2);
  strcpy(str2,str1);
  printf("將第 1 個字串內容複製到第 2 個字串後的結果\n");
  printf("第 1 個 字串 %s \n",str1);
  printf("第 2 個 字串 %s \n",str2);
  system("pause");
  return 0;
}
==============================================
/* 程式檔名:test_11-53-4.c*/
/* 程式目的:"Hello World"將字串串接再一起*/
/* 程式設計:蘇彥儒*/
/* 完成日期:20140527*/
#include <stdio.h>
#include <string.h>
int main(void)
{
  char str1[11]="Hello";
  char str2[]="World";
  printf("第 1 個 字串 %s \n",str1);
  printf("第 2 個 字串 %s \n",str2);
  strcat(str1,str2);
  printf("將第 2 個字串串接在第 1 個字串後面後的結果\n");
  printf("%s \n",str1);
  system("pause");
  return 0;
}
==============================================
/* 程式檔名:test_11-53-5.c*/
/* 程式目的:判斷是否有子字串*/
/* 程式設計:蘇彥儒*/
/* 完成日期:20140527*/
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  char str[] = "Long time ago,when I was a student";

  if(strstr(str,"me")==0)
  {
   printf("沒有子字串\n");                    
  }
  else
  {
   printf("有子字串\n");            
  }
  system("pause");
  return 0;
}
==============================================
/* 程式檔名:test_11-53-6.c*/
/* 程式目的:將字串擷取一部分串接成字串*/
/* 程式設計:蘇彥儒*/
/* 完成日期:20140527*/
#include <stdio.h>
#include <string.h>
int main(void)
{
  char str1[]="television";
  char str2[]="portion";
  char temp1[10]="";
  char temp2[10]="";
  int n;
  printf("第 1 個 字串 %s \n",str1);
  printf("第 2 個 字串 %s \n",str2);
  strncpy(temp1,str1,4);
  strncpy(temp2,str2,4);
  strcat(temp1,temp2);
  printf("串接後:\n");
  printf("%s \n",temp1);
  system("pause");
  return 0;
}
==============================================
/* 程式檔名:test_11-53-7.c*/
/* 程式目的:輸入英文字串 大小寫對調*/
/* 程式設計:蘇彥儒*/
/* 完成日期:20140527*/
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  char str[100];
  int i;
  unsigned int sl;
  printf("輸入英文\n");
  scanf("%s",&str);
  printf("原字串 %s\n",str);

  sl=strlen(str);
  for(i=0;i<sl;i++)
  {
if(str[i]<91)
str[i]=str[i]+32;
else
str[i]=str[i]-32;
  }
  printf("新字串 %s\n",str);
  system("pause");
  return 0;
}
==============================================
/* 程式檔名:test_11-53-8.c*/
/* 程式目的:輸入三科成績 計算出總和後 以"總分為XXX分"的格式輸出*/
/* 程式設計:蘇彥儒*/
/* 完成日期:20140527*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
  char sumch[]="總分為";
  char chem[]="分";
  char str_sum[10];
  char date[200];

  int num[3];
  int i,sum=0;
  for(i=0;i<3;i++)
  {
    printf("請輸入第 %d 科成績\n",i+1);
    scanf("%d",&num[i]);
    sum=sum+num[i];                    
  }
  itoa(sum,str_sum,10);
  strcat(date,sumch);
  strcat(date,str_sum);
  strcat(date,chem);
  printf("%s \n",date);
 
  system("pause");
  return 0;
}
==============================================
/* 程式檔名:test_11-53-9.c*/
/* 程式目的輸入整數然後逆印在螢幕上*/
/* 程式設計:蘇彥儒*/
/* 完成日期:20140527*/
#include <stdio.h>
int main(void)
{
    char name[100];
    int i;
 
    printf("輸入數字\n");
    scanf("%s",name);
    for(i=strlen(name)-1;i>=0;i--)
    {
printf("%c",name[i]);
    }
    system("pause");
    return 0;
}
==============================================
/* 程式檔名:test_11-53-10.c*/
/* 程式目的:查詢12個月每個月的英文名稱*/
/* 程式設計:蘇彥儒*/
/* 完成日期:20140527*/
#include <stdio.h>
#include <string.h>
#define SIZE 12

int main(void)
{
  char strary1[SIZE][12]={"一月份",
"二月份",
"三月份",
"四月份",
"五月份",
"六月份",
"七月份",
"八月份",
"九月份",
"十月份",
"十一月份",
"十二月份"};
  char strary2[SIZE][12]={"January",
 "February",
 "March",
 "April",
 "May",
 "June",
 "July",
 "August",
 "Septemper",
 "October",
 "November",
 "December"};
  char search[60];
  int position=12,i;

  printf("查詢月份英文名稱\n");
  printf("請輸入中文名稱\n");
  scanf("%s",search);

  for(i=0;i<SIZE;i++)
  {
if(strcmp(search,strary1[i])==0)
{
 position=i;
 printf("%s 的英文名稱為 %s\n",search,strary2[i]);
 break;
}
  }
  if(position==12)
printf("查無此日\n");
  system("pause");
  return 0;
}
==============================================