powershell 实现合并目录下的文件并保存到指定文件
程序员文章站
2022-04-29 15:54:37
...
# 合并目录下的所有文件,并以UTF8格式保存到指定文件 function funcCombinFilesInUTF8($fileDir, $destFile) { echo '' | out-file -Encoding utf8 -filepath $destFile $fileList = Get-ChildItem $fileDir Foreach($file in $fileList) { get-content $file.fullname | out-file -append -Encoding utf8 $destFile echo '' | out-file -append -Encoding utf8 $destFile } } function funcCombinFiles($fileDir, $destFile) { echo '' > $destFile $fileList = Get-ChildItem $fileDir Foreach($file in $fileList) { get-content $file.fullname >> $destFile echo '' >> $destFile } } funcCombinFilesInUTF8 'C:\Users\shadow\Desktop\tmp' 'C:\Users\shadow\Desktop\tmp_all.txt' funcCombinFiles 'C:\Users\shadow\Desktop\tmp' 'C:\Users\shadow\Desktop\tmp_all2.txt'
上一篇: 用WIN汇编开发桌面报时工具
下一篇: 学点powershell