[PowerShell] 从一个目录向另一个目录拷贝文件 →→→→→进入此内容的聊天室

来自 , 2019-12-02, 写在 PowerShell, 查看 110 次.
URL http://www.code666.cn/view/64a4250d
  1. #! /bin/bash -
  2.  
  3. function mycopydir( )
  4. {
  5.     if ! [ -d $2 ]
  6.     then
  7.         rm -rf $2
  8.         cp -rf $1 $2
  9.         echo "copy $1 to $2"
  10.         return 0
  11.     fi
  12.     allfiles=$(ls $1)
  13.     for one in $allfiles
  14.     do
  15.         if  [ -d  $1"/"$one ]
  16.         then
  17.             mycopydir $1"/"$one $2"/"$one
  18.             continue
  19.         fi
  20.         if [ -f $1"/"$one ]
  21.         then
  22.             if ! [ -f $2"/"$one ]
  23.             then
  24.                 rm -rf $2"/"$one
  25.                 cp -f $1"/"$one $2"/"$one
  26.                 echo "copy $1/$one to  $2/$one "
  27.             fi
  28.        fi
  29.     done
  30. }
  31.  
  32. if [ $# -lt 2 ]
  33. then
  34.     echo "must two argv!"
  35.     exit 0
  36. fi
  37.  
  38. if ! [ -d $1 ]
  39. then
  40.     echo $1"not exist!"
  41.     exit 0
  42. fi
  43.  
  44. mycopydir $1 $2
  45. exit 0
  46.  
  47. //shell/1295

回复 "从一个目录向另一个目录拷贝文件"

这儿你可以回复上面这条便签

captcha