BDMV.INFO

 Retrieve Password
 register now
Search
Hot: #
!show!: 25391|Reply: 1
Print Prev. thread Next thread

[2014.10.10] Realize the Batch Compression with Building Par2 Repair Files of Each Items @ Linux (Update) [Copy URL]

Rank: 9Rank: 9Rank: 9

Jump to a specific floor
樓主
Post time 2014-9-20 12:07:23 |Show the author posts only |Descending
Limitation & Key point:
01. The size of splited volumes of every items forcing limite to 1GB and the size of every reapir files is as close as possible the volume size unless the compressed source is less then 1GB.
02. If the size of the compressed source is more than 1TB, the script need to improve.
03.Par2 repaire files are building with some rules, and the rules is related with the par2 file name.
04.The script will automatically create some other files are convenient to let me troubleshoot issue and I don't want take off these files, gays can edit the shell script to delect these files yourself (but it is not easy).
05.Before you run the script, please install the rar and par2 in your linux.
06.Before you run the script, please edit some variable content and the content of target file to match your using environment and requirement, I will describe the examples at next part.
07.Before you compiler the source code of test7 ~ test9, please double confirm that you have already installed g++.
08.If the size of compressed source is less then 5GB, the script will force using method 11 (refer the next point) to build the single par2 reapire (core) file.
09.All the items run rar archiver with rr3 and about 15% par2 repair files, if the source size is less then 1GB, the level of redundancy of par2 automatically increase to 100%.
10.Please don't fill out any special characters in every script's variables, but the files name or folders name (blong with $dirWhere location) is allowed.

---releae notes---
2010/10/10 version 1.0
Source code:
A : script
Guys create the script first into at any path you like of your computer, but you need to edit the variable ($programWhere) to match your environment ( see the example ).
  1. #!/bin/sh

  2. # improte the variables
  3. dirWhere='/home/userid/a/'
  4. saveWhere="/home/userid/save/"
  5. programWhere="/home/userid/software/"
  6. findList="/home/userid/software/source"
  7. newNameList="/home/userid/software/target"
  8. tempList="/home/userid/software/templist"

  9. password="P.A.S.S.W.O.R.D"
  10. #10.old ,11-new
  11. par2_method="10"
  12. rarVersion="r5d11fin"
  13. #mode01=unpacket,mode02=packet
  14. information_mode="02"

  15. # check for bad situation 1
  16. if [ ! -f "$newNameList" ] ; then
  17.     echo 'error, list does not exist'
  18.     exit
  19. fi

  20. # assign the path to te working directory
  21. cd "$dirWhere"

  22. # search and get the the name of working directory
  23. find . -maxdepth 1 > $tempList
  24. cat $tempList | sort > $findList
  25. sed -i "s/\.\///g" $findList
  26. sed -i '/^\.$/d' $findList

  27. cd "$programWhere"
  28. #rm -f $tempList

  29. # check for the bad situation 2
  30. lineTotal_01=` cat "$findList" | wc -l `
  31. lineTotal_02=` cat "$newNameList" | wc -l`

  32. if [ $lineTotal_01 -ne $lineTotal_02 ] ; then
  33.     echo 'error, the list numbers does not match with the folders and files nambers of working directory。'
  34.     exit
  35. fi

  36. #start to enter the working loop

  37. # 初始化用來當迴圈「計數器」的變數的值
  38. loopTimes=1
  39. echo -e ""
  40. echo "* The core of this scrip start working *"
  41. echo -e ""
  42. # 迴圈開始
  43. while read fileName
  44. do
  45. echo "loopTimes=$loopTimes"
  46. #mapping新檔名
  47. # 新檔名 = 取出「更名列表清單」特定行數的資料
  48. # 行數 = 迴圈計數器的值(由1開始,依序增加讀取)
  49. lineNum=` echo $loopTimes"p" `
  50. newFileName=` sed -n $lineNum $newNameList `

  51. mkdir $saveWhere$newFileName

  52. sleep 2
  53. # 壓縮->修名->重新命名
  54. #壓縮

  55. if [ $loopTimes -ne 0 ] ; then
  56.     echo "$fileName" > "$dirWhere"comment
  57.     echo -e "" >> "$dirWhere"comment
  58. #echo "* This shell script is created by bdmv.info * " >> "$dirWhere"comment
  59. #echo "* People are only allowed to use the script for nonprofit reserch *" >> "$dirWhere"comment
  60.     rar a -m0 -hp"$password" -v1073741824b -rr3 -ep1 -z"$dirWhere"comment $saveWhere"$newFileName"/"$newFileName".$rarVersion.rr3 "$dirWhere""$fileName"
  61.     echo -e "\n\n"
  62.     echo "echo 1.rar壓縮"
  63.     echo -e "\n\n"
  64.     sleep  2
  65. fi

  66. #取得壓縮檔完整數量
  67. rarFileNumber=` ls -laR $saveWhere"$newFileName" |grep "^-" |awk 'END{print NR}' `
  68. rarFileSize=` ls -l $saveWhere"$newFileName" | awk '{ sum += $5} END { printf("%.3f\n",sum/1024/1024/1024)}'`
  69. echo -e "\n\n"
  70. echo "echo 2.壓縮檔數量=$rarFileNumber"
  71. echo -e "\n\n"
  72. sleep 2

  73. #新增newFileName文件放置檔按資訊
  74. echo "01.project_source          $fileName" > $saveWhere$newFileName/"$newFileName".txt
  75. echo -e "\n\n"
  76. echo "echo 3.新增文件$newFileName.txt"
  77. echo -e "\n\n"
  78. sleep 2

  79. #由來源大小取得par2所需的各項參數
  80. du -s -b "$dirWhere""$fileName" | awk '{print $1}'| "$programWhere"test7 >> $saveWhere$newFileName/"$newFileName".txt
  81. sed -n "1,10p" $saveWhere$newFileName/"$newFileName".txt
  82. echo -e "\n\n"
  83. echo "echo 4.儲存參數至$saveWhere$newFileName/"$newFileName".txt"
  84. echo -e "\n\n"
  85. sleep 2

  86. #由壓縮檔數量取得par2所需的各項參數
  87. echo "$rarFileNumber" | "$programWhere"test8 >> $saveWhere$newFileName/"$newFileName".txt
  88. sed -n "1,12p" $saveWhere$newFileName/"$newFileName".txt
  89. echo -e "\n\n"
  90. echo "echo 5.儲存參數至$saveWhere$newFileName/"$newFileName".txt"
  91. echo -e "\n\n"
  92. sleep 2


  93. #比對rar檔案數量做更名
  94. #echo "$fileName" > "$dirWhere"comment
  95. #echo -e "" >> "$dirWhere"comment
  96. #echo "* This shell script is created by bdmv.info * " >> "$dirWhere"comment
  97. #echo "* People are only allowed to use the script for nonprofit reserch *" >> "$dirWhere"comment

  98. #if [ "$rarFileNumber" -gt 99 ] ; then
  99. #    rar c -p$password -z"$dirWhere"comment $saveWhere"$newFileName"/"$newFileName".$rarVersion.rr3.part001.rar
  100. #    rename.ul part "" $saveWhere"$newFileName"/* && rename.ul .rar "" $saveWhere"$newFileName"/*
  101. #    echo -e "\n\n\n"
  102. #    echo "echo 6.更名:模式1(檔案大小>1)"
  103. #elif [ "$rarFileNumber" -gt 9 ] ; then
  104. #        rar c -p$password -z"$dirWhere"comment $saveWhere"$newFileName"/"$newFileName".$rarVersion.rr3.part01.rar
  105. #        rename.ul part "" $saveWhere"$newFileName"/* && rename.ul .rar "" $saveWhere"$newFileName"/*
  106. #        echo -e "\n\n\n"
  107. #        echo "echo 6.更名:模式1(檔案大小>1)"
  108. if [ "$rarFileNumber" -gt 1 ] ; then
  109.         rename.ul part "" $saveWhere"$newFileName"/* && rename.ul .rar "" $saveWhere"$newFileName"/*
  110.         echo -e "\n\n\n"
  111.         echo "echo 6.更名:模式1(檔案大小>1)"
  112. else
  113.         rar c -p$password -z"$dirWhere"comment $saveWhere"$newFileName"/"$newFileName".$rarVersion.rr3
  114.     rename -v 's/rr3$/rr3\.1/' $saveWhere"$newFileName"/*
  115.     echo -e "\n\n"
  116.     echo "echo 6.更名:模式2(檔案大小<=1)"
  117. fi
  118. rm "$dirWhere"comment

  119. echo -e "\n\n"
  120. sleep 2

  121. #讀入參數九:count
  122. volume_beta=` sed -n 9p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `  #9指向count,par2 method=10
  123. volume=` sed -n 12p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `  #12指向count2,par2 method=11
  124. if [ "$volume" -eq 0 ] ; then
  125.     rarVolumeFileSize=` du -S -b $saveWhere$newFileName/*rr3.* | grep rr3 | awk '{sum += $1};END{print sum}' `
  126. else
  127.     rarVolumeFileSize=` du -S -b $saveWhere$newFileName/*rr3."$volume"* | grep rr3."$volume" | awk '{sum += $1};END{print sum}' `
  128. fi

  129. echo "volume=$volume"
  130. echo "rarVolumeFileSize=$rarVolumeFileSize"
  131. echo -e "\n\n"
  132. echo "echo 7.取出卷數資訊計算未滿100(99)的末尾分卷大小"
  133. echo -e "\n\n"
  134. sleep 2
  135. #製作數狀圖
  136. #tree "$dirWhere""$fileName" >> $saveWhere"$newFileName"/"$newFileName".tree.txt
  137. #sed -i 's#'$dirWhere'##' $saveWhere"$newFileName"/"$newFileName".tree.txt
  138. #rar a -hp"$password" -ep1 $saveWhere"$newFileName"/"$newFileName".tree.rar $saveWhere"$newFileName"/"$newFileName".tree.txt
  139. #sed -n "1,5p" "$saveWhere$newFileName"/"$newFileName".tree.txt
  140. #echo "echo 7.Print 樹狀圖(前五列)"
  141. #rm $saveWhere"$newFileName"/"$newFileName".tree.txt
  142. #sleep 5
  143. tree "$dirWhere""$fileName" >> $saveWhere"$newFileName"/"$newFileName".tree.txt
  144. tree -d "$dirWhere""$fileName" >> $saveWhere"$newFileName"/"$newFileName".folder.tree.txt
  145. sed -i '1d' $saveWhere"$newFileName"/"$newFileName".tree.txt
  146. sed -i '1d' $saveWhere"$newFileName"/"$newFileName".folder.tree.txt
  147. if [ $loopTimes -ne 1 ] ; then
  148.         echo -e "" >> $saveWhere"$newFileName"/"$newFileName".tree2.txt
  149.         echo -e "" >> $saveWhere"$newFileName"/"$newFileName".tree3.txt
  150. fi
  151. echo "$fileName" >> $saveWhere"$newFileName"/"$newFileName".tree2.txt
  152. echo "$fileName" >> $saveWhere"$newFileName"/"$newFileName".tree3.txt
  153. awk '{print $0}' $saveWhere"$newFileName"/"$newFileName".tree.txt  >> $saveWhere"$newFileName"/"$newFileName".tree2.txt
  154. awk '{print $0}' $saveWhere"$newFileName"/"$newFileName".folder.tree.txt  >> $saveWhere"$newFileName"/"$newFileName".tree3.txt
  155. awk '{print $0}' $saveWhere"$newFileName"/"$newFileName".tree2.txt > $saveWhere"$newFileName"/"$newFileName".tree.txt
  156. awk '{print $0}' $saveWhere"$newFileName"/"$newFileName".tree3.txt > $saveWhere"$newFileName"/"$newFileName".folder.tree.txt
  157. rm $saveWhere"$newFileName"/"$newFileName".tree2.txt
  158. rm $saveWhere"$newFileName"/"$newFileName".tree3.txt
  159. sed -n "1,5p" "$saveWhere$newFileName"/"$newFileName".tree.txt
  160. sed -n "1,5p" "$saveWhere$newFileName"/"$newFileName".folder.tree.txt
  161. echo -e "\n\n"
  162. echo "echo 8.Print 樹狀圖*2(前五列)"
  163. echo -e "\n\n"
  164. sleep 3

  165. #由count大小判定par2最末未滿100(99)分卷的檔名&強制修正par2的使用時機
  166. if [ $rarFileNumber -lt 5 ] ; then
  167.         par2_method="11"
  168. fi

  169. if [ $par2_method -eq 11 ] ; then
  170.     if [ $volume -gt 0 ] ; then
  171.         volume2="$volume"00-End
  172.         volume2=` echo ""$volume"00-End" `
  173.     else
  174.         if [ $rarFileNumber -lt 10 ] ; then
  175.             volume2=1-End
  176.         else
  177.             volume2=01-End
  178.         fi
  179.     fi
  180. else
  181.     if [ $volume -gt 0 ] ; then
  182.             if [ $volume -eq $volume_beta ] ;then
  183.                     volume2="$volume"00-End
  184.                     volume2=` echo ""$volume"00-End" `
  185.             elif [ $volume -gt $volume_beta ] ;then
  186.                     volume2="$volume_beta"00-"$volume_beta"99
  187.             fi
  188.     else
  189.             if [ $rarFileNumber -lt 10 ] ; then
  190.                     volume2=1-End
  191.             else
  192.                     volume2=01-End
  193.             fi
  194.     fi
  195. fi

  196. echo -e "\n\n"
  197. echo "echo 9.volume2=$volume2"
  198. echo -e "\n\n"
  199. sleep 2

  200. #取得par2參數(rr/rbs/rbn2)
  201. echo "$rarVolumeFileSize" | "$programWhere"test9 >>  $saveWhere$newFileName/"$newFileName".txt
  202. sed -n "1,15p" $saveWhere$newFileName/"$newFileName".txt
  203. echo -e "\n\n"
  204. echo "echo 10.新增參數13-15"
  205. echo -e "\n\n"
  206. sleep 2

  207. #txt文件的變數取代
  208. bc=` sed -n 6p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `
  209. rbc=` sed -n 7p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `
  210. rbn1=` sed -n 8p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `
  211. rr=` sed -n 13p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `
  212. rbs=` sed -n 14p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `
  213. rbn2=` sed -n 15p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `

  214. sed -i 's/$bc/'$bc'/g' $saveWhere$newFileName/$newFileName.txt
  215. sed -i 's/$rbc/'$rbc'/g' $saveWhere$newFileName/$newFileName.txt
  216. sed -i 's/$rbn1/'$rbn1'/g' $saveWhere$newFileName/$newFileName.txt
  217. sed -i 's/$rr/'$rr'/g' $saveWhere$newFileName/$newFileName.txt
  218. sed -i 's/$rbs/'$rbs'/g' $saveWhere$newFileName/$newFileName.txt
  219. sed -i 's/$rbn2/'$rbn2'/g' $saveWhere$newFileName/$newFileName.txt
  220. sed -i 's#$saveWhere#'$saveWhere'#g' $saveWhere$newFileName/$newFileName.txt
  221. sed -i 's/$newFileName/'$newFileName'/g' $saveWhere$newFileName/$newFileName.txt
  222. sed -i 's/$rarVersion/'$rarVersion'/g' $saveWhere$newFileName/$newFileName.txt

  223. #檔案數量大於99的情況取消$volume2字串
  224. if [ $par2_method -eq 11 ] ; then
  225.     if [ $volume -gt 0 ] ; then
  226.             sed -i 's/$volume2/'"$volume2"'/g' $saveWhere$newFileName/$newFileName.txt
  227.     else
  228.             sed -i 's#$volume2'\.'##g'  $saveWhere$newFileName/$newFileName.txt
  229.     fi
  230. else
  231.     if [ $volume -gt 0 ] ; then
  232.             if [ $volume_beta -gt 0 ] ; then
  233.                     sed -i 's/$volume2/'"$volume2"'/g' $saveWhere$newFileName/$newFileName.txt
  234.             else
  235.                     sed -i 's#$volume2'\.'##g'  $saveWhere$newFileName/$newFileName.txt
  236.             fi
  237.     else
  238.             sed -i 's#$volume2'\.'##g'  $saveWhere$newFileName/$newFileName.txt
  239.     fi
  240. fi

  241. sed -n "1,15p"  $saveWhere$newFileName/"$newFileName".txt
  242. echo -e "\n\n"
  243. echo "echo 11.txt文件的變數取代"
  244. echo -e "\n\n"
  245. sleep 2

  246. #dump par2 command至$newFileName.par2command.txt
  247. sed -n "$par2_method"p $saveWhere$newFileName/$newFileName.txt|sed -r "s/(&&)/\n/g" > $saveWhere$newFileName/$newFileName.par2command.txt

  248. if [ $par2_method -eq 10 ] ; then
  249.     volume_plus=` expr $volume_beta + 2 `
  250. elif [ $par2_method -eq 11 ] ;then
  251.         volume_plus=` expr $volume + 2 `
  252. fi

  253. sed -n 1,"$volume_plus"p $saveWhere$newFileName/$newFileName.par2command.txt
  254. echo -e "\n\n"
  255. echo "echo 12.par2 command + cfv command"
  256. echo -e "\n\n"
  257. sleep 2

  258. #執行par2與cfv製作
  259. count=1
  260. while [ "$count" -le "$volume_plus" ]
  261. do
  262.     command=` sed -n "$count"p $saveWhere$newFileName/$newFileName.par2command.txt `
  263.     $command
  264.     count=` expr $count + 1 `
  265. done
  266. echo -e "\n\n"
  267. echo "echo 13.par2與cfv製作完成"
  268. echo -e "\n\n"
  269. sleep 2

  270. #修正sfv內容
  271. sed -i 's#'$saveWhere$newFileName/'##' $saveWhere$newFileName/$newFileName.sfv
  272. sed -i "/$newFileName.par2command.txt/d" $saveWhere$newFileName/$newFileName.sfv
  273. sed -i "/$newFileName.tree.txt/d" $saveWhere$newFileName/$newFileName.sfv
  274. sed -i "/$newFileName.folder.tree.txt/d" $saveWhere$newFileName/$newFileName.sfv
  275. sed -i "/$newFileName.txt/d" $saveWhere$newFileName/$newFileName.sfv
  276. awk '{print $0}' $saveWhere$newFileName/$newFileName.sfv >> "$saveWhere"ALL.FILENAME.sfv
  277. sed -n "1,10p" $saveWhere$newFileName/$newFileName.sfv
  278. echo "echo 14.修正sfv內容v1"
  279. echo -e "\n\n"
  280. sleep 2
  281. echo -e "\n\n"

  282. #整理$newFileName的檔案
  283. par2FileSize=` ls -l $saveWhere"$newFileName"/*.par2 | awk '{ sum += $5} END { printf("%.3f\n",sum/1024/1024/1024)}' `
  284. sed -i "10,11d" $saveWhere$newFileName/$newFileName.txt
  285. sed -i -r "s/(^09.)/11\./g" $saveWhere$newFileName/$newFileName.txt
  286. sed -i -r "s/(^08.)/10\./g" $saveWhere$newFileName/$newFileName.txt
  287. sed -i -r "s/(^07.)/09\./g" $saveWhere$newFileName/$newFileName.txt
  288. sed -i -r "s/(^06.)/08\./g" $saveWhere$newFileName/$newFileName.txt
  289. sed -i -r "s/(^05.)/07\./g" $saveWhere$newFileName/$newFileName.txt
  290. sed -i "5 i\05.size(item/rar)(gb)      $rarFileSize" $saveWhere$newFileName/$newFileName.txt
  291. sed -i "6 i\06.size(item/par2)(gb)     $par2FileSize" $saveWhere$newFileName/$newFileName.txt
  292. echo "--------par2 + cfv command--------" >>$saveWhere$newFileName/$newFileName.txt
  293. sed -n 1,"$volume_plus"p $saveWhere$newFileName/$newFileName.par2command.txt >> $saveWhere$newFileName/$newFileName.txt
  294. echo "##################################" >> $saveWhere$newFileName/$newFileName.txt

  295. sed -i 's#'$saveWhere'#($saveWhere)#g' $saveWhere$newFileName/$newFileName.txt

  296. rm $saveWhere$newFileName/$newFileName.par2command.txt
  297. volume_plus=` expr $volume_plus + 17 `
  298. sed -n 1,"$volume_plus"p $saveWhere"$newFileName"/"$newFileName".txt
  299. echo -e "\n\n"
  300. echo "echo 15.最終版$newFileName.txt內容"
  301. echo -e "\n\n"
  302. sleep 2

  303. #新增mapping/target/size對照文件
  304. echo "$newFileName" >> "$saveWhere"ALL.FILE.MAP.txt
  305. sizegb=` sed -n 3p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `
  306. sizemb=` du -s "$dirWhere""$fileName" | awk '{ printf("%.3f\n",$1/1024)}' `
  307. sed -i -r ""$loopTimes"s/$/    source|"$sizegb"GB/g" "$saveWhere"ALL.FILE.MAP.txt
  308. sed -i -r ""$loopTimes"s/$/    source|"$sizemb"MB/g" "$saveWhere"ALL.FILE.MAP.txt
  309. sed -i -r ""$loopTimes"s/$/    rar|"$rarFileSize"GB/g" "$saveWhere"ALL.FILE.MAP.txt
  310. sed -i -r ""$loopTimes"s/$/    par2|"$par2FileSize"GB/g" "$saveWhere"ALL.FILE.MAP.txt
  311. sed -i -r ""$loopTimes"s/$/    $fileName/g" "$saveWhere"ALL.FILE.MAP.txt
  312. sed -n 1,"$loopTimes"p "$saveWhere"ALL.FILE.MAP.txt
  313. echo -e "\n\n"
  314. echo "echo 16.loop$loopTimes的map內容"
  315. echo -e "\n\n"
  316. sleep 2

  317. #打包並刪除$newFileName.txt(保留全卷資訊)
  318. test "$information_mode" = "01" && rar a -m0 -ep1 -hp$password $saveWhere$newFileName/$newFileName.information.rar $saveWhere$newFileName/$newFileName.txt $saveWhere$newFileName/$newFileName.tree.txt $saveWhere$newFileName/$newFileName.folder.tree.txt
  319. #test "$information_mode" = "02" && rar a -m0 -ep1 -hp$password $saveWhere$newFileName.information.v2.rar $saveWhere$newFileName/$newFileName.sfv $saveWhere"$newFileName"/"$newFileName".$rarVersion.rr3.par2 $saveWhere$newFileName/$newFileName.txt $saveWhere$newFileName/$newFileName.tree.txt $saveWhere$newFileName/$newFileName.folder.tree.txt ; rm $saveWhere$newFileName/$newFileName.sfv ; rm $saveWhere"$newFileName"/"$newFileName".$rarVersion.rr3.par2
  320. if [ "$information_mode" = "02" ] ; then
  321.     rar a -m0 -ep1 -hp$password $saveWhere$newFileName.information.v2.rar $saveWhere$newFileName/$newFileName.sfv $saveWhere"$newFileName"/"$newFileName".$rarVersion.rr3.par2 $saveWhere$newFileName/$newFileName.txt $saveWhere$newFileName/$newFileName.tree.txt $saveWhere$newFileName/$newFileName.folder.tree.txt
  322.     rm $saveWhere$newFileName/$newFileName.sfv
  323.     rm $saveWhere"$newFileName"/"$newFileName".$rarVersion.rr3.par2
  324. fi
  325. awk '{print $0}' $saveWhere$newFileName/$newFileName.txt >> "$saveWhere"ALL.FILENAME.txt
  326. awk '{print $0}' $saveWhere$newFileName/$newFileName.tree.txt >> "$saveWhere"ALL.TREE\(PART.MODE\).txt
  327. awk '{print $0}' $saveWhere$newFileName/$newFileName.folder.tree.txt >> "$saveWhere"ALL.FOLDER.TREE\(PART.MODE\).txt
  328. rm $saveWhere$newFileName/$newFileName.txt
  329. rm $saveWhere$newFileName/$newFileName.tree.txt
  330. rm $saveWhere$newFileName/$newFileName.folder.tree.txt
  331. echo -e "\n\n"
  332. echo "echo 17.打包並刪除$newFileName.txt(保留全卷資訊)"
  333. echo -e "\n\n"
  334. sleep 2
  335. # 迴圈計數器 + 1
  336. loopTimes=` expr $loopTimes + 1 `
  337. project_end=$newFileName
  338. done < $findList

  339. #打包全卷資訊
  340. echo -e "" >> "$saveWhere"ALL.TREE\(FULL.MODE\).txt
  341. echo -e "" >> "$saveWhere"ALL.FOLDER.TREE\(FULL.MODE\).txt
  342. tree "$dirWhere" >> "$saveWhere"ALL.TREE\(FULL.MODE\).txt
  343. tree -d "$dirWhere" >> "$saveWhere"ALL.FOLDER.TREE\(FULL.MODE\).txt
  344. sed -i '2d' "$saveWhere""ALL.TREE(FULL.MODE).txt"
  345. sed -i '2d' "$saveWhere""ALL.FOLDER.TREE(FULL.MODE).txt"
  346. project_start=` sed -n 1p $newNameList `
  347. test "$project_start" != "$project_end" && rar a -m0 -ep1 -hp$password "$saveWhere"\["$project_start"\].to.\["$project_end"\].ALL.INFORMATION.rar "$saveWhere"ALL.FILENAME.txt "$saveWhere"ALL.TREE\(PART.MODE\).txt "$saveWhere"ALL.FILE.MAP.txt "$saveWhere"ALL.TREE\(FULL.MODE\).txt "$saveWhere"ALL.FOLDER.TREE\(FULL.MODE\).txt "$saveWhere"ALL.FOLDER.TREE\(PART.MODE\).txt "$saveWhere"ALL.FILENAME.sfv && test "$information_mode" = "02" && rar a -m0 -ep1 -hp$password "$saveWhere"\("$project_start"\).to.\("$project_end"\).information.v2.packet.rar "$saveWhere"*.information.v2.rar && rm "$saveWhere"*.information.v2.rar
  348. test "$project_start" = "$project_end" && rar a -m0 -ep1 -hp$password "$saveWhere"\["$project_end"\].ALL.INFORMATION.rar "$saveWhere"ALL.FILENAME.txt "$saveWhere"ALL.TREE\(PART.MODE\).txt "$saveWhere"ALL.FILE.MAP.txt "$saveWhere"ALL.TREE\(FULL.MODE\).txt "$saveWhere"ALL.FOLDER.TREE\(FULL.MODE\).txt "$saveWhere"ALL.FOLDER.TREE\(PART.MODE\).txt "$saveWhere"ALL.FILENAME.sfv

  349. #刪除暫存檔
  350. rm "$saveWhere"ALL.FILE.MAP.txt
  351. rm "$saveWhere"ALL.FILENAME.txt
  352. rm "$saveWhere"ALL.TREE\(PART.MODE\).txt
  353. rm "$saveWhere"ALL.TREE\(FULL.MODE\).txt
  354. rm "$saveWhere"ALL.FOLDER.TREE\(PART.MODE\).txt
  355. rm "$saveWhere"ALL.FOLDER.TREE\(FULL.MODE\).txt
  356. rm "$saveWhere"ALL.FILENAME.sfv
  357. rm -f $findList
  358. #rm -f $newNameList
  359. rm -f $tempList
  360. echo -e ""
  361. echo "* All the jobs are finished *"
  362. echo -e ""
Copy the Code
Pay attention of the variables of

dirWhere=batch compressd files source
saveWhere=where are the compressed files saving as
programWhere=where are the test7 to test9 binary files saving as
findList=a specified file script will add source (file/folder) name into automatically
newNameList= the new item name of the compressed source
tempList=a specified file adding some temp information
password=password of the rar achiver
par2_method=only can select the mode 10 or 11
rarVersion=the tag name of rar version
information_mode=only can select the mode 01 or 02

And, not only fill out  the absolate path of the variables of dirWhere to tempList ,but assign the file name belonging with findList、 newNameList and tempList.
Final, add the new name inforamtion into the file belonging with newNameList.

Give an example and a illustration to everyone :
1. If we hope to move the 10 folders (these name are 01、02、03... 10 )and 1 file (the name is 11) I want to do compress to the specified location(source locaion  = $dirWhere =  /home/id/compress/) and  specify the name of the compress files of each item are c-01、c-02、c-03 ... c-11 and I want to save all the compressed volume and par2 reapir files to the another location(target location = $saveWhere = /home/id/save/)

2.I create the shell script and test7~test9 (I will describe at next part) at  another location(/home/id/script/)

3.Use - P.A.S.S.W.O.R.D as the compress files' password  

4.par2_method is a very complex part, I like the mode 10 but , because of people don't understand the throey of mode 10 nad 11, I suggest people use mode 11.

5.The version of rar we use to do compress is 5.11, so we use the word - r5d11fin to be the version tag.

6.Use the mode 01 to get the sparate information of every single item.

7.Edit the variable conents of shell script, like the below parameters:
dirWhere= /home/id/compress/
saveWhere=location /home/id/save/
programWhere=/home/id/script/
findList=/home/id/script/source
newNameList= /home/id/script/target
tempList=/home/id/script/temp
password="P.A.S.S.W.O.R.D"
par2_method="10"
rarVersion="r5d11fin"
information_mode="01"

8.I also need to edit the file of (newNameList) - /home/id/script/target and improte the content liking the below block
  1. c-01
  2. c-02
  3. c-03
  4. c-04
  5. c-05
  6. c-06
  7. c-07
  8. c-08
  9. c-09
  10. c-10
Copy the Code
Give everyone another example picture to illustrate the information_mode 2
Like the above example, the files (and folders) of left putty window belog to $dirWhere and the location of center window belong to $saveWhere.
We arrived the result to know the  content of target file are G201405.No-01、G201405.No-02、G201405.No-03 ... by the illustration of deduction .
The illustration is the saame as the above example using the information mode2m people can see the center region ((G201405.No-01).to.(G201405.No-91).information.v2.packet.rar) of the illusration.

B : Other source code
The test7 ~ test9 can help the script to calculate some parameters and load the parameters into par2 to build par2 files, before running the script ,people must compiler these source codes youself and move the program into the location belong to $programWhere

How to compiler  the source code, people can refer this command.
  1. g++ -c test7.cpp; g++ -o test7 test7.o
Copy the Code
test7.cpp
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <iostream>
  5. #include <string>
  6. #include <sstream>

  7. using namespace std;
  8. using std::cout;
  9. using std::string;
  10. //using std::basic_stringstream;


  11. int main(int argc, char **argv)
  12. {
  13.     FILE   *instream;
  14.     int    bytes_read=0;
  15.     int    buffer_size=0;
  16.     char   calculate[100];
  17.     double calculate_double;
  18.     double size;
  19.     double size2;
  20.     double multi;
  21.     double block_size;
  22.     double block_count;
  23.     double repair_number;
  24.     int    count=0;
  25.     string str1;
  26.     string str2;
  27.     string str3;
  28.     string str4;
  29.     string str5;
  30.     string str6;
  31.     string str7;
  32.     string str8;
  33.     string str9;
  34.     string stra;

  35. //    char str1[];

  36.     /* open stdin for reading */
  37.     instream=fopen("/dev/stdin","r");

  38.     /* did it open? */
  39.     if(instream!=NULL){
  40.         /* read from stdin until it's end */
  41.         fgets(calculate,100,instream);
  42.         calculate [99] = '\0';
  43.         calculate_double = atof(calculate);
  44.         size = (calculate_double / (1024*1024*1024));  //source size
  45.         size2 = size * 1.03;

  46.         if (size <= 108)
  47.         {
  48.             if (size <= 74)
  49.                 multi = 1.1;
  50.             else if (size <= 81 && size > 74)
  51.                 multi = 1.1 + ((1.11 - 1.1) * (size - 74) / (81 - 74));
  52.             else if (size <= 88 && size > 81)
  53.                 multi = 1.11 + ((1.12 - 1.11) * (size -81) / (88 - 81));
  54.             else if (size <= 105 && size > 88)
  55.                 multi = 1.12 + ((1.15 - 1.12) * (size -88) / (105 - 88));
  56.             else if (size <= 108 && size > 105)
  57.                 multi = 1.15 + ((1.155 - 1.15) * (size - 105) /(108 - 105));

  58.             block_size = size2 * multi * 5;
  59.             repair_number = block_size * 0.15 / 6; //省去浮點數使用
  60.             repair_number = ceil(repair_number);
  61.             block_count = double (int (repair_number) * 6);
  62.             count = 0;

  63.         }
  64.         else if (size <=195 && size > 108)
  65.         {
  66.             if (size <= 114)
  67.                 multi = 1.05;
  68.             else if (size <= 119 && size >114)
  69.                 multi = 1.05 + ((1.13 - 1.05) * (size - 114) / (119 - 114));
  70.             else if (size <= 139 && size > 119)
  71.                 multi = 1.13 + ((1.135 - 1.13) * (size - 119) / (139 - 119));
  72.             else if (size <= 169 && size > 139)
  73.                 multi = 1.135 + ((1.14 - 1.135) * (size - 139) / (169 - 139));
  74.             else if (size <= 190 && size > 169)
  75.                 multi = 1.14 + ((1.145 - 1.14) * (size -169) / (190 - 169));
  76.             else if (size <= 195 && size > 190)
  77.                 multi =1.145 + ((1.149 -1.145 ) * (size - 190) / (195 - 190));

  78.             block_size = (size2 - 99) * multi * 5;
  79.             repair_number = block_size * 0.15 / 6; //省去浮點數使用
  80.             repair_number = ceil(repair_number);
  81.             block_count = double (int (repair_number) * 6);
  82.             count = 1;
  83.         }
  84.         else if (size <= 292 && size > 195)
  85.         {
  86.             if (size <= 202 )
  87.                 multi = 0.5;
  88.             else if (size <= 211 && size > 202)
  89.                 multi = 0.5 + ((0.65 - 0.5) * (size - 202) / (211 - 202));
  90.             else if (size <= 222 && size > 211)
  91.                 multi = 0.65 + ((1.03 - 0.65) * (size - 211) / (222 - 211));
  92.             else if (size <= 239 && size > 222)
  93.                 multi = 1.03 + ((1.08 - 1.03) * (size - 222) / (239 - 222));
  94.             else if (size <= 256 && size > 239)
  95.                 multi = 1.08 + ((1.135 - 1.08) * (size - 239) / (256 -239));
  96.             else if (size <= 292 && size > 256)
  97.                 multi = 1.135 + ((1.145 - 1.135) * (size - 256) / (292 - 256));

  98.             block_size = (size2 - 199) * multi * 5;
  99.             repair_number = block_size * 0.15 / 6; //省去浮點數使用
  100.             repair_number = ceil(repair_number);
  101.             block_count = double (int (repair_number) * 6);
  102.             count = 2;

  103.         }
  104.         else if (size <= 393 && size > 292)
  105.         {
  106.             if (size <= 310)
  107.                 multi = 0.7;
  108.             else if (size <= 324 && size > 310)
  109.                 multi = 0.7 + ((0.95 - 0.7) * (size - 310) / (324 - 310));
  110.             else if (size <= 330 && size > 324)
  111.                 multi =  0.95 + ((1 - 0.95) * (size - 324) / (330 - 324));
  112.             else if (size <= 348 && size > 330)
  113.                 multi = 1 + ((1.04 - 1) * (size -330) / (348 - 330));
  114.             else if (size <= 393 && size > 348)
  115.                 multi =  1.04 + ((1.1 - 1.04) * (size - 348) / (364 - 348));

  116.             block_size = (size2 - 299) * multi * 5;
  117.             repair_number = block_size * 0.15 / 6; //省去浮點數使用
  118.             repair_number = ceil(repair_number);
  119.             block_count = double (int (repair_number) * 6);
  120.             count = 3;

  121.         }
  122.         else if (size <= 490 && size > 393)
  123.         {
  124.             if (size <= 409)
  125.                 multi = 0.6;
  126.             else if (size <= 417 && size > 409)
  127.                 multi = 0.6 + ((0.8 - 0.6) * (size - 409) / (417 - 409));
  128.             else if (size <=  490 && size > 417)
  129.                 multi = 0.8 + ((1.1 - 0.8) * (size - 417) / (490 - 417));

  130.             block_size = (size2 - 399) * multi * 5;
  131.             repair_number = block_size * 0.15 / 6; //省去浮點數使用
  132.             repair_number = ceil(repair_number);
  133.             block_count = double (int (repair_number) * 6);
  134.             count = 4;

  135.         }
  136.         else if (size <= 587 && size > 490)
  137.         {
  138.             if (size <= 517)
  139.                 multi = 0.7;
  140.             else if ( size <= 587 && size > 517)
  141.                 multi = 0.7 + ((1.1 - 0.7) * (size - 517) / (587 -517));

  142.             block_size = (size2 - 499) * multi * 5;
  143.             repair_number = block_size * 0.15 / 6; //省去浮點數使用
  144.             repair_number = ceil(repair_number);
  145.             block_count = double (int (repair_number) * 6);
  146.             count = 5;

  147.         }
  148.         else if (size <= 684 && size > 587)
  149.         {
  150.             if (size <= 628)
  151.                 multi = 0.85;
  152.             else if ( size <= 684 && size > 628)
  153.                 multi = 0.85 + ((1.1 - 0.85) * (size -628) / ( 684 - 628));

  154.             block_size = (size2 - 599) * multi * 5;
  155.             repair_number = block_size * 0.15 / 6; //省去浮點數使用
  156.             repair_number = ceil(repair_number);
  157.             block_count = double (int (repair_number) * 6);
  158.             count = 6;
  159.         }
  160.         else
  161.         {
  162.             multi = 1;
  163.             size2 = size *1.03;

  164.             while(size2 > 100 )
  165.             {
  166.                 if(count == 0)
  167.                     size2 = size2 - 99;
  168.                 else
  169.                     size2 = size2 -100;
  170.                 count = count + 1;
  171.             }

  172.             block_size = size2 * multi * 5;
  173.             repair_number = block_size * 0.15 / 6; //省去浮點數使用
  174.             repair_number = ceil(repair_number);
  175.             block_count = double (int (repair_number) * 6);
  176.         }

  177.         if(count <= 9)
  178.         {
  179.             int i;
  180.             int j;
  181.             for(i = 0 ;i <= count;i++)
  182.             {
  183.                 if( i != count)
  184.                 {
  185.                     if(i == 0)
  186.                     {
  187.                         stringstream convert;
  188.                         convert << i;
  189.                         str1 = "par2 c -b575 -c90 -n15 -u $saveWhere$newFileName/$newFileName.$rarVersion.rr3.001-099.par2 $saveWhere$newFileName/$newFileName.$rarVersion.rr3.";
  190.                         str2 = convert.str();
  191.                         str3 = "*&&";
  192.                         str8 = str1 + str2 + str3;
  193.                     }
  194.                     else
  195.                     {
  196.                         str1 = "par2 c -b582 -c90 -n15 -u $saveWhere$newFileName/$newFileName.$rarVersion.rr3.";
  197.                         stringstream convert_i;
  198.                         convert_i << i;
  199.                         str2 = convert_i.str();
  200.                         str3 = "00-";
  201.                     //    j = i + 1;
  202.                     //    stringstream convert_j;
  203.                     //    convert_j << j;
  204.                     //    str4 = convert_j.str();
  205.                         str5 = "99.par2 $saveWhere$newFileName/$newFileName.$rarVersion.rr3.";
  206.                         str6 = "*&&";
  207.                         str8 = str8 + str1 + str2 + str3 + str2 +str5 + str2 + str6;
  208.                     }

  209.                 }
  210.                 else if(i == count)
  211.                 {
  212.                     if(count == 0)
  213.                     {
  214.                         str1 = "par2 c -b$bc -c$rbc -n$rbn1 -u $saveWhere$newFileName/$newFileName.$rarVersion.rr3.$volume2.par2 $saveWhere$newFileName/$newFileName.$rarVersion.rr3.";
  215.                         str2 = "par2 c -r$rr -s$rbs -n$rbn2 -u $saveWhere$newFileName/$newFileName.$rarVersion.rr3.$volume2.par2 $saveWhere$newFileName/$newFileName.$rarVersion.rr3.";
  216.                         str4 = "*&&cfv -C -tsfv -f$saveWhere$newFileName/$newFileName.sfv $saveWhere$newFileName/*";
  217.                         str9 = str8 + str1 + str4;
  218.                     }
  219.                     else
  220.                     {
  221.                         stringstream convert;
  222.                         convert << count;
  223.                         str1 = "par2 c -b$bc -c$rbc -n$rbn1 -u $saveWhere$newFileName/$newFileName.$rarVersion.rr3.$volume2.par2 $saveWhere$newFileName/$newFileName.$rarVersion.rr3.";
  224.                         str2 = "par2 c -r$rr -s$rbs -n$rbn2 -u $saveWhere$newFileName/$newFileName.$rarVersion.rr3.$volume2.par2 $saveWhere$newFileName/$newFileName.$rarVersion.rr3.";
  225.                         str3 = convert.str();
  226.                         str4 = "*&&cfv -C -tsfv -f$saveWhere$newFileName/$newFileName.sfv $saveWhere$newFileName/*";
  227.                         str9 = str8 + str1 + str3 + str4;
  228.                     }
  229.                 }
  230.             }
  231.         }

  232.         printf("02.size(bit)               %.0f\n03.size(source)(gb)        %.3f\n04.size(source*1.03)(gb)   %.3f\n05.multi                   %.2f\n06.block_count(bc)         %.0f\n07.Recovery_count(rbc)     %.0f\n08.repire_number(rbn1)     %.0f\n09.count1                  %d\n",calculate_double,size,size2,multi,block_size,block_count,repair_number,count);
  233.         cout << str9 << endl;
  234.         fclose(instream);

  235.     }
  236.     /* if any error occured, exit with an error message */
  237.     else{
  238.         fprintf(stderr, "ERROR opening stdin. aborting.\n");
  239.         exit(1);
  240.     }

  241.     return(0);
  242. }
Copy the Code
test8.cpp
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <iostream>
  5. #include <string>
  6. #include <sstream>

  7. using namespace std;
  8. using std::cout;
  9. using std::string;
  10. //using std::basic_stringstream;


  11. int main(int argc, char **argv)
  12. {
  13.     FILE   *instream;
  14.     int    bytes_read=0;
  15.     int    buffer_size=0;
  16.     char   calculate[100];
  17.     double calculate_double;
  18.     double number;
  19.     int count;

  20.     string str1;
  21.     string str2;
  22.     string str3;
  23.     string str4;
  24.     string str5;
  25.     string str6;
  26.     string str7;
  27.     string str8;
  28.     string str9;
  29.     string stra;

  30. //    char str1[];

  31.     /* open stdin for reading */
  32.     instream=fopen("/dev/stdin","r");

  33.     /* did it open? */
  34.     if(instream!=NULL){
  35.         /* read from stdin until it's end */
  36.         fgets(calculate,100,instream);
  37.         calculate [99] = '\0';
  38.         calculate_double = atof(calculate);
  39.         number = calculate_double;  //rarFileNumber

  40.     if(number < 100)
  41.     {
  42.         count = 0;
  43.     }
  44.     else
  45.     {
  46.         count = floor((number - 1) / 100);
  47.     }

  48.     if(count <= 9)
  49.     {
  50.         int i;
  51.         int j;
  52.         for(i = 0 ;i <= count;i++)
  53.         {
  54.             if( i != count)
  55.             {
  56.                 if(i == 0)
  57.                 {
  58.                     stringstream convert;
  59.                     convert << i;
  60.                     str1 = "par2 c -b575 -c90 -n15 -u $saveWhere$newFileName/$newFileName.$rarVersion.rr3.001-099.par2 $saveWhere$newFileName/$newFileName.$rarVersion.rr3.";
  61.                     str2 = convert.str();
  62.                     str3 = "*&&";
  63.                     str8 = str1 + str2 + str3;
  64.                 }
  65.                 else
  66.                 {
  67.                     str1 = "par2 c -b582 -c90 -n15 -u $saveWhere$newFileName/$newFileName.$rarVersion.rr3.";
  68.                     stringstream convert_i;
  69.                     convert_i << i;
  70.                     str2 = convert_i.str();
  71.                     str3 = "00-";
  72.                     j = i + 1;
  73.                     stringstream convert_j;
  74.                     convert_j << j;
  75.                     str4 = convert_j.str();
  76.                     str5 = "00.par2 $saveWhere$newFileName/$newFileName.$rarVersion.rr3.";
  77.                     str6 = "*&&";
  78.                     str8 = str8 + str1 + str2 + str3 + str4 +str5 + str2 + str6;
  79.                 }

  80.             }
  81.             else if(i == count)
  82.             {
  83.                 if(count == 0)
  84.                 {
  85.                     str1 = "par2 c -b$bc -c$rbc -n$rbn1 -u $saveWhere$newFileName/$newFileName.$rarVersion.rr3.$volume2.par2 $saveWhere$newFileName/$newFileName.$rarVersion.rr3.";
  86.                     str2 = "par2 c -r$rr -s$rbs -n$rbn2 -u $saveWhere$newFileName/$newFileName.$rarVersion.rr3.$volume2.par2 $saveWhere$newFileName/$newFileName.$rarVersion.rr3.";
  87.                     str4 = "*&&cfv -C -tsfv -f$saveWhere$newFileName/$newFileName.sfv $saveWhere$newFileName/*";
  88.                     stra = str8 + str2 + str4;
  89.                 }
  90.                 else
  91.                 {
  92.                     stringstream convert;
  93.                     convert << count;
  94.                     str1 = "par2 c -b$bc -c$rbc -n$rbn1 -u $saveWhere$newFileName/$newFileName.$rarVersion.rr3.$volume2.par2 $saveWhere$newFileName/$newFileName.$rarVersion.rr3.";
  95.                     str2 = "par2 c -r$rr -s$rbs -n$rbn2 -u $saveWhere$newFileName/$newFileName.$rarVersion.rr3.$volume2.par2 $saveWhere$newFileName/$newFileName.$rarVersion.rr3.";
  96.                     str3 = convert.str();
  97.                     str4 = "*&&cfv -C -tsfv -f$saveWhere$newFileName/$newFileName.sfv $saveWhere$newFileName/*";
  98.                     stra = str8 + str2 + str3 + str4;
  99.                 }
  100.             }
  101.         }
  102.     }

  103.         cout << stra << endl;
  104.         printf("12.count2                  %d\n",count);

  105.         fclose(instream);

  106.     }
  107.     /* if any error occured, exit with an error message */
  108.     else{
  109.         fprintf(stderr, "ERROR opening stdin. aborting.\n");
  110.         exit(1);
  111.     }

  112.     return(0);
  113. }
Copy the Code
test9.cpp
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <iostream>
  5. #include <string>
  6. #include <sstream>

  7. using namespace std;
  8. using std::cout;
  9. using std::string;
  10. //using std::basic_stringstream;


  11. int main(int argc, char **argv)
  12. {
  13.     FILE   *instream;
  14.     int    bytes_read=0;
  15.     int    buffer_size=0;
  16.     char   calculate[100];
  17.     double calculate_double;
  18.     double size;
  19.     double size_GB;
  20.     double repair_size;
  21.     double rbn2;
  22.     double rr;
  23.     double rbs;

  24.     string str1;
  25.     string str2;
  26.     string str3;


  27. //    char str1[];

  28.     /* open stdin for reading */
  29.     instream=fopen("/dev/stdin","r");

  30.     /* did it open? */
  31.     if(instream!=NULL){
  32.         /* read from stdin until it's end */
  33.         fgets(calculate,100,instream);
  34.         calculate [99] = '\0';
  35.         calculate_double = atof(calculate);
  36.         size = calculate_double;  //bit,rarVolumeFileSize
  37.         size_GB = calculate_double / (1024*1024*1024);
  38.         repair_size = size * 0.15 / (1024*1024*1024);
  39.         rbn2 = ceil(repair_size);  //N GB repair files
  40.         rr = ceil(rbn2 * (1024*1024*1024) * 100 / size); //N (GB)*1024^3修復檔/源檔大小= rr precent
  41.         rbs = ((ceil(((size * rr / 100) / (rbn2 * 7)) / 4 )) * 4);        

  42.         if(size_GB < rbn2)
  43.         {
  44.             rr =100;
  45.             rbs = (ceil((size / 7) / 4) * 4);
  46.             rbn2 = 1;

  47.         }


  48.         printf("13.level(rr)               %.0f\n14.block_size(rbs)         %.0f\n15.repire_number(rbn2)     %.0f\n",rr,rbs,rbn2);
  49.         fclose(instream);

  50.     }
  51.     /* if any error occured, exit with an error message */
  52.     else{
  53.         fprintf(stderr, "ERROR opening stdin. aborting.\n");
  54.         exit(1);
  55.     }

  56.     return(0);
  57. }
Copy the Code
After adding the shell script (script.sh) and move test7~test9 to the same folder, change the script's premission then we can use the scirpt to add a job.
  1. chmod 755 script.sh test7 test8 test9 && ./script.sh
Copy the Code

Rank: 9Rank: 9Rank: 9

沙發
Post time 2014-10-10 15:24:23 |Show the author posts only
---release notes---
2014/10/10 version 1.1b
1.Add new variable $dataWhere, fill out the information in real patch of data source,then the script will auto move the datato $dirWhere and move back the data after finish the cimpression.
2.The contents  of test7 to test9 are the same.
2014/10/10 version 1.2b
1.Fix the variable of the part of moving files and allow the special character file/folder name!!
2.The contents  of test7 to test9 are the same.

Source code of script
  1. #!/bin/sh

  2. # improte the variables
  3. dataWhere='/home/userid/data/'
  4. dirWhere='/home/userid/a/'
  5. saveWhere="/home/userid/save/"
  6. programWhere="/home/userid/software/"
  7. findList="/home/userid/software/source"
  8. newNameList="/home/userid/software/target"
  9. tempList="/home/userid/software/templist"

  10. password="P.A.S.S.W.O.R.D"
  11. #10.old ,11-new
  12. par2_method="10"
  13. rarVersion="r5d11fin"
  14. #mode01=unpacket,mode02=packet
  15. information_mode="02"

  16. #collect data
  17. while read fileName
  18. do
  19. mv $dataWhere"$fileName" $dirWhere
  20. done < $findList
  21. echo "* The data is finish collected *"

  22. # check for bad situation 1
  23. if [ ! -f "$newNameList" ] ; then
  24.     echo 'error, list does not exist'
  25.     exit
  26. fi

  27. # assign the path to te working directory
  28. cd "$dirWhere"

  29. # search and get the the name of working directory
  30. find . -maxdepth 1 > $tempList
  31. cat $tempList | sort > $findList
  32. sed -i "s/\.\///g" $findList
  33. sed -i '/^\.$/d' $findList

  34. cd "$programWhere"
  35. #rm -f $tempList

  36. # check for the bad situation 2
  37. lineTotal_01=` cat "$findList" | wc -l `
  38. lineTotal_02=` cat "$newNameList" | wc -l`

  39. if [ $lineTotal_01 -ne $lineTotal_02 ] ; then
  40.     echo 'error, the list numbers does not match with the folders and files nambers of working directory。'
  41.     exit
  42. fi

  43. #start to enter the working loop

  44. # 初始化用來當迴圈「計數器」的變數的值
  45. loopTimes=1
  46. echo -e ""
  47. echo "* The core of this scrip start working *"
  48. echo -e ""
  49. # 迴圈開始
  50. while read fileName
  51. do
  52. echo "loopTimes=$loopTimes"
  53. #mapping新檔名
  54. # 新檔名 = 取出「更名列表清單」特定行數的資料
  55. # 行數 = 迴圈計數器的值(由1開始,依序增加讀取)
  56. lineNum=` echo $loopTimes"p" `
  57. newFileName=` sed -n $lineNum $newNameList `

  58. mkdir $saveWhere$newFileName

  59. sleep 2
  60. # 壓縮->修名->重新命名
  61. #壓縮

  62. if [ $loopTimes -ne 0 ] ; then
  63.     echo "$fileName" > "$dirWhere"comment
  64.     echo -e "" >> "$dirWhere"comment
  65. #echo "* This shell script is created by bdmv.info * " >> "$dirWhere"comment
  66. #echo "* People are only allowed to use the script for nonprofit reserch *" >> "$dirWhere"comment
  67.     rar a -m0 -hp"$password" -v1073741824b -rr3 -ep1 -z"$dirWhere"comment $saveWhere"$newFileName"/"$newFileName".$rarVersion.rr3 "$dirWhere""$fileName"
  68.     echo -e "\n\n"
  69.     echo "echo 1.rar壓縮"
  70.     echo -e "\n\n"
  71.     sleep  2
  72. fi

  73. #取得壓縮檔完整數量
  74. rarFileNumber=` ls -laR $saveWhere"$newFileName" |grep "^-" |awk 'END{print NR}' `
  75. rarFileSize=` ls -l $saveWhere"$newFileName" | awk '{ sum += $5} END { printf("%.3f\n",sum/1024/1024/1024)}'`
  76. echo -e "\n\n"
  77. echo "echo 2.壓縮檔數量=$rarFileNumber"
  78. echo -e "\n\n"
  79. sleep 2

  80. #新增newFileName文件放置檔按資訊
  81. echo "01.project_source          $fileName" > $saveWhere$newFileName/"$newFileName".txt
  82. echo -e "\n\n"
  83. echo "echo 3.新增文件$newFileName.txt"
  84. echo -e "\n\n"
  85. sleep 2

  86. #由來源大小取得par2所需的各項參數
  87. du -s -b "$dirWhere""$fileName" | awk '{print $1}'| "$programWhere"test7 >> $saveWhere$newFileName/"$newFileName".txt
  88. sed -n "1,10p" $saveWhere$newFileName/"$newFileName".txt
  89. echo -e "\n\n"
  90. echo "echo 4.儲存參數至$saveWhere$newFileName/"$newFileName".txt"
  91. echo -e "\n\n"
  92. sleep 2

  93. #由壓縮檔數量取得par2所需的各項參數
  94. echo "$rarFileNumber" | "$programWhere"test8 >> $saveWhere$newFileName/"$newFileName".txt
  95. sed -n "1,12p" $saveWhere$newFileName/"$newFileName".txt
  96. echo -e "\n\n"
  97. echo "echo 5.儲存參數至$saveWhere$newFileName/"$newFileName".txt"
  98. echo -e "\n\n"
  99. sleep 2


  100. #比對rar檔案數量做更名
  101. #echo "$fileName" > "$dirWhere"comment
  102. #echo -e "" >> "$dirWhere"comment
  103. #echo "* This shell script is created by bdmv.info * " >> "$dirWhere"comment
  104. #echo "* People are only allowed to use the script for nonprofit reserch *" >> "$dirWhere"comment

  105. #if [ "$rarFileNumber" -gt 99 ] ; then
  106. #    rar c -p$password -z"$dirWhere"comment $saveWhere"$newFileName"/"$newFileName".$rarVersion.rr3.part001.rar
  107. #    rename.ul part "" $saveWhere"$newFileName"/* && rename.ul .rar "" $saveWhere"$newFileName"/*
  108. #    echo -e "\n\n\n"
  109. #    echo "echo 6.更名:模式1(檔案大小>1)"
  110. #elif [ "$rarFileNumber" -gt 9 ] ; then
  111. #        rar c -p$password -z"$dirWhere"comment $saveWhere"$newFileName"/"$newFileName".$rarVersion.rr3.part01.rar
  112. #        rename.ul part "" $saveWhere"$newFileName"/* && rename.ul .rar "" $saveWhere"$newFileName"/*
  113. #        echo -e "\n\n\n"
  114. #        echo "echo 6.更名:模式1(檔案大小>1)"
  115. if [ "$rarFileNumber" -gt 1 ] ; then
  116.         rename.ul part "" $saveWhere"$newFileName"/* && rename.ul .rar "" $saveWhere"$newFileName"/*
  117.         echo -e "\n\n\n"
  118.         echo "echo 6.更名:模式1(檔案大小>1)"
  119. else
  120.         rar c -p$password -z"$dirWhere"comment $saveWhere"$newFileName"/"$newFileName".$rarVersion.rr3
  121.     rename -v 's/rr3$/rr3\.1/' $saveWhere"$newFileName"/*
  122.     echo -e "\n\n"
  123.     echo "echo 6.更名:模式2(檔案大小<=1)"
  124. fi
  125. rm "$dirWhere"comment

  126. echo -e "\n\n"
  127. sleep 2

  128. #讀入參數九:count
  129. volume_beta=` sed -n 9p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `  #9指向count,par2 method=10
  130. volume=` sed -n 12p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `  #12指向count2,par2 method=11
  131. if [ "$volume" -eq 0 ] ; then
  132.     rarVolumeFileSize=` du -S -b $saveWhere$newFileName/*rr3.* | grep rr3 | awk '{sum += $1};END{print sum}' `
  133. else
  134.     rarVolumeFileSize=` du -S -b $saveWhere$newFileName/*rr3."$volume"* | grep rr3."$volume" | awk '{sum += $1};END{print sum}' `
  135. fi

  136. echo "volume=$volume"
  137. echo "rarVolumeFileSize=$rarVolumeFileSize"
  138. echo -e "\n\n"
  139. echo "echo 7.取出卷數資訊計算未滿100(99)的末尾分卷大小"
  140. echo -e "\n\n"
  141. sleep 2
  142. #製作數狀圖
  143. #tree "$dirWhere""$fileName" >> $saveWhere"$newFileName"/"$newFileName".tree.txt
  144. #sed -i 's#'$dirWhere'##' $saveWhere"$newFileName"/"$newFileName".tree.txt
  145. #rar a -hp"$password" -ep1 $saveWhere"$newFileName"/"$newFileName".tree.rar $saveWhere"$newFileName"/"$newFileName".tree.txt
  146. #sed -n "1,5p" "$saveWhere$newFileName"/"$newFileName".tree.txt
  147. #echo "echo 7.Print 樹狀圖(前五列)"
  148. #rm $saveWhere"$newFileName"/"$newFileName".tree.txt
  149. #sleep 5
  150. tree "$dirWhere""$fileName" >> $saveWhere"$newFileName"/"$newFileName".tree.txt
  151. tree -d "$dirWhere""$fileName" >> $saveWhere"$newFileName"/"$newFileName".folder.tree.txt
  152. sed -i '1d' $saveWhere"$newFileName"/"$newFileName".tree.txt
  153. sed -i '1d' $saveWhere"$newFileName"/"$newFileName".folder.tree.txt
  154. if [ $loopTimes -ne 1 ] ; then
  155.         echo -e "" >> $saveWhere"$newFileName"/"$newFileName".tree2.txt
  156.         echo -e "" >> $saveWhere"$newFileName"/"$newFileName".tree3.txt
  157. fi
  158. echo "$fileName" >> $saveWhere"$newFileName"/"$newFileName".tree2.txt
  159. echo "$fileName" >> $saveWhere"$newFileName"/"$newFileName".tree3.txt
  160. awk '{print $0}' $saveWhere"$newFileName"/"$newFileName".tree.txt  >> $saveWhere"$newFileName"/"$newFileName".tree2.txt
  161. awk '{print $0}' $saveWhere"$newFileName"/"$newFileName".folder.tree.txt  >> $saveWhere"$newFileName"/"$newFileName".tree3.txt
  162. awk '{print $0}' $saveWhere"$newFileName"/"$newFileName".tree2.txt > $saveWhere"$newFileName"/"$newFileName".tree.txt
  163. awk '{print $0}' $saveWhere"$newFileName"/"$newFileName".tree3.txt > $saveWhere"$newFileName"/"$newFileName".folder.tree.txt
  164. rm $saveWhere"$newFileName"/"$newFileName".tree2.txt
  165. rm $saveWhere"$newFileName"/"$newFileName".tree3.txt
  166. sed -n "1,5p" "$saveWhere$newFileName"/"$newFileName".tree.txt
  167. sed -n "1,5p" "$saveWhere$newFileName"/"$newFileName".folder.tree.txt
  168. echo -e "\n\n"
  169. echo "echo 8.Print 樹狀圖*2(前五列)"
  170. echo -e "\n\n"
  171. sleep 3

  172. #由count大小判定par2最末未滿100(99)分卷的檔名&強制修正par2的使用時機
  173. if [ $rarFileNumber -lt 5 ] ; then
  174.         par2_method="11"
  175. fi

  176. if [ $par2_method -eq 11 ] ; then
  177.     if [ $volume -gt 0 ] ; then
  178.         volume2="$volume"00-End
  179.         volume2=` echo ""$volume"00-End" `
  180.     else
  181.         if [ $rarFileNumber -lt 10 ] ; then
  182.             volume2=1-End
  183.         else
  184.             volume2=01-End
  185.         fi
  186.     fi
  187. else
  188.     if [ $volume -gt 0 ] ; then
  189.             if [ $volume -eq $volume_beta ] ;then
  190.                     volume2="$volume"00-End
  191.                     volume2=` echo ""$volume"00-End" `
  192.             elif [ $volume -gt $volume_beta ] ;then
  193.                     volume2="$volume_beta"00-"$volume_beta"99
  194.             fi
  195.     else
  196.             if [ $rarFileNumber -lt 10 ] ; then
  197.                     volume2=1-End
  198.             else
  199.                     volume2=01-End
  200.             fi
  201.     fi
  202. fi

  203. echo -e "\n\n"
  204. echo "echo 9.volume2=$volume2"
  205. echo -e "\n\n"
  206. sleep 2

  207. #取得par2參數(rr/rbs/rbn2)
  208. echo "$rarVolumeFileSize" | "$programWhere"test9 >>  $saveWhere$newFileName/"$newFileName".txt
  209. sed -n "1,15p" $saveWhere$newFileName/"$newFileName".txt
  210. echo -e "\n\n"
  211. echo "echo 10.新增參數13-15"
  212. echo -e "\n\n"
  213. sleep 2

  214. #txt文件的變數取代
  215. bc=` sed -n 6p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `
  216. rbc=` sed -n 7p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `
  217. rbn1=` sed -n 8p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `
  218. rr=` sed -n 13p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `
  219. rbs=` sed -n 14p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `
  220. rbn2=` sed -n 15p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `

  221. sed -i 's/$bc/'$bc'/g' $saveWhere$newFileName/$newFileName.txt
  222. sed -i 's/$rbc/'$rbc'/g' $saveWhere$newFileName/$newFileName.txt
  223. sed -i 's/$rbn1/'$rbn1'/g' $saveWhere$newFileName/$newFileName.txt
  224. sed -i 's/$rr/'$rr'/g' $saveWhere$newFileName/$newFileName.txt
  225. sed -i 's/$rbs/'$rbs'/g' $saveWhere$newFileName/$newFileName.txt
  226. sed -i 's/$rbn2/'$rbn2'/g' $saveWhere$newFileName/$newFileName.txt
  227. sed -i 's#$saveWhere#'$saveWhere'#g' $saveWhere$newFileName/$newFileName.txt
  228. sed -i 's/$newFileName/'$newFileName'/g' $saveWhere$newFileName/$newFileName.txt
  229. sed -i 's/$rarVersion/'$rarVersion'/g' $saveWhere$newFileName/$newFileName.txt

  230. #檔案數量大於99的情況取消$volume2字串
  231. if [ $par2_method -eq 11 ] ; then
  232.     if [ $volume -gt 0 ] ; then
  233.             sed -i 's/$volume2/'"$volume2"'/g' $saveWhere$newFileName/$newFileName.txt
  234.     else
  235.             sed -i 's#$volume2'\.'##g'  $saveWhere$newFileName/$newFileName.txt
  236.     fi
  237. else
  238.     if [ $volume -gt 0 ] ; then
  239.             if [ $volume_beta -gt 0 ] ; then
  240.                     sed -i 's/$volume2/'"$volume2"'/g' $saveWhere$newFileName/$newFileName.txt
  241.             else
  242.                     sed -i 's#$volume2'\.'##g'  $saveWhere$newFileName/$newFileName.txt
  243.             fi
  244.     else
  245.             sed -i 's#$volume2'\.'##g'  $saveWhere$newFileName/$newFileName.txt
  246.     fi
  247. fi

  248. sed -n "1,15p"  $saveWhere$newFileName/"$newFileName".txt
  249. echo -e "\n\n"
  250. echo "echo 11.txt文件的變數取代"
  251. echo -e "\n\n"
  252. sleep 2

  253. #dump par2 command至$newFileName.par2command.txt
  254. sed -n "$par2_method"p $saveWhere$newFileName/$newFileName.txt|sed -r "s/(&&)/\n/g" > $saveWhere$newFileName/$newFileName.par2command.txt

  255. if [ $par2_method -eq 10 ] ; then
  256.     volume_plus=` expr $volume_beta + 2 `
  257. elif [ $par2_method -eq 11 ] ;then
  258.         volume_plus=` expr $volume + 2 `
  259. fi

  260. sed -n 1,"$volume_plus"p $saveWhere$newFileName/$newFileName.par2command.txt
  261. echo -e "\n\n"
  262. echo "echo 12.par2 command + cfv command"
  263. echo -e "\n\n"
  264. sleep 2

  265. #執行par2與cfv製作
  266. count=1
  267. while [ "$count" -le "$volume_plus" ]
  268. do
  269.     command=` sed -n "$count"p $saveWhere$newFileName/$newFileName.par2command.txt `
  270.     $command
  271.     count=` expr $count + 1 `
  272. done
  273. echo -e "\n\n"
  274. echo "echo 13.par2與cfv製作完成"
  275. echo -e "\n\n"
  276. sleep 2

  277. #修正sfv內容
  278. sed -i 's#'$saveWhere$newFileName/'##' $saveWhere$newFileName/$newFileName.sfv
  279. sed -i "/$newFileName.par2command.txt/d" $saveWhere$newFileName/$newFileName.sfv
  280. sed -i "/$newFileName.tree.txt/d" $saveWhere$newFileName/$newFileName.sfv
  281. sed -i "/$newFileName.folder.tree.txt/d" $saveWhere$newFileName/$newFileName.sfv
  282. sed -i "/$newFileName.txt/d" $saveWhere$newFileName/$newFileName.sfv
  283. awk '{print $0}' $saveWhere$newFileName/$newFileName.sfv >> "$saveWhere"ALL.FILENAME.sfv
  284. sed -n "1,10p" $saveWhere$newFileName/$newFileName.sfv
  285. echo "echo 14.修正sfv內容v1"
  286. echo -e "\n\n"
  287. sleep 2
  288. echo -e "\n\n"

  289. #整理$newFileName的檔案
  290. par2FileSize=` ls -l $saveWhere"$newFileName"/*.par2 | awk '{ sum += $5} END { printf("%.3f\n",sum/1024/1024/1024)}' `
  291. sed -i "10,11d" $saveWhere$newFileName/$newFileName.txt
  292. sed -i -r "s/(^09.)/11\./g" $saveWhere$newFileName/$newFileName.txt
  293. sed -i -r "s/(^08.)/10\./g" $saveWhere$newFileName/$newFileName.txt
  294. sed -i -r "s/(^07.)/09\./g" $saveWhere$newFileName/$newFileName.txt
  295. sed -i -r "s/(^06.)/08\./g" $saveWhere$newFileName/$newFileName.txt
  296. sed -i -r "s/(^05.)/07\./g" $saveWhere$newFileName/$newFileName.txt
  297. sed -i "5 i\05.size(item/rar)(gb)      $rarFileSize" $saveWhere$newFileName/$newFileName.txt
  298. sed -i "6 i\06.size(item/par2)(gb)     $par2FileSize" $saveWhere$newFileName/$newFileName.txt
  299. echo "--------par2 + cfv command--------" >>$saveWhere$newFileName/$newFileName.txt
  300. sed -n 1,"$volume_plus"p $saveWhere$newFileName/$newFileName.par2command.txt >> $saveWhere$newFileName/$newFileName.txt
  301. echo "##################################" >> $saveWhere$newFileName/$newFileName.txt

  302. sed -i 's#'$saveWhere'#($saveWhere)#g' $saveWhere$newFileName/$newFileName.txt

  303. rm $saveWhere$newFileName/$newFileName.par2command.txt
  304. volume_plus=` expr $volume_plus + 17 `
  305. sed -n 1,"$volume_plus"p $saveWhere"$newFileName"/"$newFileName".txt
  306. echo -e "\n\n"
  307. echo "echo 15.最終版$newFileName.txt內容"
  308. echo -e "\n\n"
  309. sleep 2

  310. #新增mapping/target/size對照文件
  311. echo "$newFileName" >> "$saveWhere"ALL.FILE.MAP.txt
  312. sizegb=` sed -n 3p $saveWhere$newFileName/$newFileName.txt | awk '{print $2}' `
  313. sizemb=` du -s "$dirWhere""$fileName" | awk '{ printf("%.3f\n",$1/1024)}' `
  314. sed -i -r ""$loopTimes"s/$/    source|"$sizegb"GB/g" "$saveWhere"ALL.FILE.MAP.txt
  315. sed -i -r ""$loopTimes"s/$/    source|"$sizemb"MB/g" "$saveWhere"ALL.FILE.MAP.txt
  316. sed -i -r ""$loopTimes"s/$/    rar|"$rarFileSize"GB/g" "$saveWhere"ALL.FILE.MAP.txt
  317. sed -i -r ""$loopTimes"s/$/    par2|"$par2FileSize"GB/g" "$saveWhere"ALL.FILE.MAP.txt
  318. sed -i -r ""$loopTimes"s/$/    $fileName/g" "$saveWhere"ALL.FILE.MAP.txt
  319. sed -n 1,"$loopTimes"p "$saveWhere"ALL.FILE.MAP.txt
  320. echo -e "\n\n"
  321. echo "echo 16.loop$loopTimes的map內容"
  322. echo -e "\n\n"
  323. sleep 2

  324. #打包並刪除$newFileName.txt(保留全卷資訊)
  325. test "$information_mode" = "01" && rar a -m0 -ep1 -hp$password $saveWhere$newFileName/$newFileName.information.rar $saveWhere$newFileName/$newFileName.txt $saveWhere$newFileName/$newFileName.tree.txt $saveWhere$newFileName/$newFileName.folder.tree.txt
  326. #test "$information_mode" = "02" && rar a -m0 -ep1 -hp$password $saveWhere$newFileName.information.v2.rar $saveWhere$newFileName/$newFileName.sfv $saveWhere"$newFileName"/"$newFileName".$rarVersion.rr3.par2 $saveWhere$newFileName/$newFileName.txt $saveWhere$newFileName/$newFileName.tree.txt $saveWhere$newFileName/$newFileName.folder.tree.txt ; rm $saveWhere$newFileName/$newFileName.sfv ; rm $saveWhere"$newFileName"/"$newFileName".$rarVersion.rr3.par2
  327. if [ "$information_mode" = "02" ] ; then
  328.     rar a -m0 -ep1 -hp$password $saveWhere$newFileName.information.v2.rar $saveWhere$newFileName/$newFileName.sfv $saveWhere"$newFileName"/"$newFileName".$rarVersion.rr3.par2 $saveWhere$newFileName/$newFileName.txt $saveWhere$newFileName/$newFileName.tree.txt $saveWhere$newFileName/$newFileName.folder.tree.txt
  329.     rm $saveWhere$newFileName/$newFileName.sfv
  330.     rm $saveWhere"$newFileName"/"$newFileName".$rarVersion.rr3.par2
  331. fi
  332. awk '{print $0}' $saveWhere$newFileName/$newFileName.txt >> "$saveWhere"ALL.FILENAME.txt
  333. awk '{print $0}' $saveWhere$newFileName/$newFileName.tree.txt >> "$saveWhere"ALL.TREE\(PART.MODE\).txt
  334. awk '{print $0}' $saveWhere$newFileName/$newFileName.folder.tree.txt >> "$saveWhere"ALL.FOLDER.TREE\(PART.MODE\).txt
  335. rm $saveWhere$newFileName/$newFileName.txt
  336. rm $saveWhere$newFileName/$newFileName.tree.txt
  337. rm $saveWhere$newFileName/$newFileName.folder.tree.txt
  338. echo -e "\n\n"
  339. echo "echo 17.打包並刪除$newFileName.txt(保留全卷資訊)"
  340. echo -e "\n\n"
  341. sleep 2
  342. # 迴圈計數器 + 1
  343. loopTimes=` expr $loopTimes + 1 `
  344. project_end=$newFileName
  345. done < $findList

  346. #打包全卷資訊
  347. echo -e "" >> "$saveWhere"ALL.TREE\(FULL.MODE\).txt
  348. echo -e "" >> "$saveWhere"ALL.FOLDER.TREE\(FULL.MODE\).txt
  349. tree "$dirWhere" >> "$saveWhere"ALL.TREE\(FULL.MODE\).txt
  350. tree -d "$dirWhere" >> "$saveWhere"ALL.FOLDER.TREE\(FULL.MODE\).txt
  351. sed -i '2d' "$saveWhere""ALL.TREE(FULL.MODE).txt"
  352. sed -i '2d' "$saveWhere""ALL.FOLDER.TREE(FULL.MODE).txt"
  353. project_start=` sed -n 1p $newNameList `
  354. test "$project_start" != "$project_end" && rar a -m0 -ep1 -hp$password "$saveWhere"\["$project_start"\].to.\["$project_end"\].ALL.INFORMATION.rar "$saveWhere"ALL.FILENAME.txt "$saveWhere"ALL.TREE\(PART.MODE\).txt "$saveWhere"ALL.FILE.MAP.txt "$saveWhere"ALL.TREE\(FULL.MODE\).txt "$saveWhere"ALL.FOLDER.TREE\(FULL.MODE\).txt "$saveWhere"ALL.FOLDER.TREE\(PART.MODE\).txt "$saveWhere"ALL.FILENAME.sfv && test "$information_mode" = "02" && rar a -m0 -ep1 -hp$password "$saveWhere"\("$project_start"\).to.\("$project_end"\).information.v2.packet.rar "$saveWhere"*.information.v2.rar && rm "$saveWhere"*.information.v2.rar
  355. test "$project_start" = "$project_end" && rar a -m0 -ep1 -hp$password "$saveWhere"\["$project_end"\].ALL.INFORMATION.rar "$saveWhere"ALL.FILENAME.txt "$saveWhere"ALL.TREE\(PART.MODE\).txt "$saveWhere"ALL.FILE.MAP.txt "$saveWhere"ALL.TREE\(FULL.MODE\).txt "$saveWhere"ALL.FOLDER.TREE\(FULL.MODE\).txt "$saveWhere"ALL.FOLDER.TREE\(PART.MODE\).txt "$saveWhere"ALL.FILENAME.sfv

  356. while read fileName
  357. do
  358. mv $dirWhere"$fileName" $dataWhere
  359. done < $findList
  360. echo "* The data is finish moving back *"

  361. #刪除暫存檔
  362. rm "$saveWhere"ALL.FILE.MAP.txt
  363. rm "$saveWhere"ALL.FILENAME.txt
  364. rm "$saveWhere"ALL.TREE\(PART.MODE\).txt
  365. rm "$saveWhere"ALL.TREE\(FULL.MODE\).txt
  366. rm "$saveWhere"ALL.FOLDER.TREE\(PART.MODE\).txt
  367. rm "$saveWhere"ALL.FOLDER.TREE\(FULL.MODE\).txt
  368. rm "$saveWhere"ALL.FILENAME.sfv
  369. rm -f $findList
  370. #rm -f $newNameList
  371. rm -f $tempList
  372. echo -e ""
  373. echo "* All the jobs are finished *"
  374. echo -e ""
Copy the Code



Use magic Report

You have to log in before you can reply Login | register now

Archiver|Cell Phone|BDMV.INFO

GMT+8, 2024-12-22 16:08 , Processed in 0.020768 second(s), 5 queries , Xcache On.

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

Top