我們經常遇到批量檔案轉碼後壓縮打包,為此我編寫了乙個perl指令碼,執行指令碼檔案後自動實現這些功能。
#!/usr/bin/perl
usestrict;
my@array=(
"110","
120",
"130","
140",
"150","
210",
"212","
220",
"230","
310",
"320","
330",
"332","
340",
"350","
352",
"360","
370",
"372","
410",
"420","
430",
"440","
443",
"450","
460",
"500","
510",
"520","
530",
"540
");
my$utf8_path = "
/tmp/";
#count the files.
my$file_count=0;#
get files_name.
my@file_name_array
;opendir(dir,$utf8_path) or die
"can't open the directory!";
@file_name_array=readdir dir;
這裡運用了正規表示式,判斷資料夾下的檔案是否符合要求,如果符合,則進行後面的計算。
實現檔案計數,檔名處理,轉碼等功能。
foreachmy$file_name (@file_name_array
)else
}
#this is tar function.
my$tar="
tar -zcvf
"."gz.tar
"."*.txt";
`$tar
"$tar
"."success!\n
";
#loop every number,tar and move files to 36 directories.
foreach
my$number(@array
"**********==$file_count
"."files cat
"."success!!!**********===\n
";
批量檔案轉碼壓縮打包Perl指令碼
我們經常遇到批量檔案轉碼後壓縮打包,為此我編寫了乙個perl指令碼,執行指令碼檔案後自動實現這些功能。usr bin perl use strict my array 110 120 130 140 150 210 212 220 230 310 320 330 332 340 350 352 36...
檔案壓縮打包
1.gzip 1 gzip gzip 檔案 生成.gz檔案 2 gzip 6 預設級別 3 gzip d 壓縮檔案 解壓縮 4 gunzip 壓縮檔案 解壓縮 5 zcat 壓縮檔案 檢視壓縮檔案內容 2.bzip2 1 bzip2 檔案 生成.bz2檔案 2 bzip2 9 預設級別 3 bzip...
檔案壓縮與打包
檔案壓縮原理 目前計算機都是使用所謂的byte來計量的,而事實上最小的計量單位應該是bit,而 byte 8bit,而對於數字 byte也就是乙個bit,相當於浪費了7個bit,因此可以壓縮。linux常見的壓縮命令 壓縮檔案的拓展名一般是 tar gz tgz等 gzip最常見的壓縮命令 壓縮檔案...