AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-1742204

Tyrone Hirt's questions

Martin Hope
Tyrone Hirt
Asked: 2024-01-04 12:23:59 +0800 CST

在 powershell 中计算 robocopy 输出的匹配项

  • 7

我有以下 robocopy 命令行:

robocopy $drv "B:\Blending Produções - Backup\Blending Produções - Tyrone Hirt - BC" /e /NJH /NDL /NC /BYTES /MT:4 /l /xd /A-:SH $IgnorarPastas /xf $IgnorarArquivos

该命令将列出必须按照既定参数复制的所有文件。

重点是:我想找到一种方法来计算将复制多少文件。

为此,我正在尝试一种方法来计算 robocopy 输出中有多少个匹配“T:”,但我没有得到预期的结果......

这是我的完整脚本:

$drv = "T:\"
$IgnorarPastas = "03. Proxy", "`$Recycle.Bin"
$IgnorarArquivos = "*.avi", "*.ini"

robocopy $drv "B:\Blending Produções - Backup\Blending Produções - Tyrone Hirt - BC" /e /NJH /NDL /NC /BYTES /MT:4 /l /xd /A-:SH $IgnorarPastas /xf $IgnorarArquivos
            
$robocopyCommand = "robocopy $drv ""B:\Blending Produções - Backup\Blending Produções - Tyrone Hirt - BC"" /e /NJH /NDL /NC /BYTES /MT:4 /l /xd /A-:SH $IgnorarPastas /xf $IgnorarArquivos"
$filesToCopy = Invoke-Expression $robocopyCommand
$numberOfFiles = ($filesToCopy | Select-String -Pattern "T:\\" -AllMatches).Matches.Count
            
write-host "`nNumber of files to be copied " -NoNewline -f White; write-host "$numberOfFiles" -NoNewline -f Green;

这是控制台中脚本的输出:

$drv = "T:\"
 $IgnorarPastas = "03. Proxy", "`$Recycle.Bin"
 $IgnorarArquivos = "*.avi", "*.ini"

robocopy $drv "B:\Blending Produções - Backup\Blending Produções - Tyrone Hirt - BC" /e /NJH /NDL /NC /BYTES /MT:4 /l /xd /A-:SH $IgnorarPastas /xf $IgnorarArquivos


$comandoRobocopy = "robocopy $drv ""B:\Blending Produções - Backup\Blending Produções - Tyrone Hirt - BC"" /e /NJH /NDL /NC /BYTES /MT:4 /l /xd /A-:SH $IgnorarPastas /xf $IgnorarArquivos"


$robocopyCommand = "robocopy $drv ""B:\Blending Produções - Backup\Blending Produções - Tyrone Hirt - BC"" /e /NJH /NDL /NC /BYTES /MT:4 /l /xd /A-:SH $IgnorarPastas /xf $IgnorarArquivos"
$filesToCopy = Invoke-Expression $robocopyCommand
$numberOfFiles = ($filesToCopy | Select-String -Pattern "T:\\" -AllMatches).Matches.Count

    
    write-host "`nNumber of files to be copied " -NoNewline -f White; write-host "$numberOfFiles" -NoNewline -f Green;

               12680    T:\_Ferramenta Backup\Backup Local\_\BP - Backup Script - Root of this device - Get Backup.ps1
100%  
            379568522   B:\Blending Produ‡äes - Backup\Blending Produ‡äes - Tyrone Hirt - BC\Blending Produ‡äes\02. Clientes\2023\Grupo Teste\Teste Car\_Imagens\Drone\DJI_0001.MOV
            2380021041  B:\Blending Produ‡äes - Backup\Blending Produ‡äes - Tyrone Hirt - BC\Blending Produ‡äes\02. Clientes\2023\Grupo Teste\Teste Car\_Imagens\Drone\DJI_0002.MOV
            43588300    B:\Blending Produ‡äes - Backup\Blending Produ‡äes - Tyrone Hirt - BC\Blending Produ‡äes\02. Clientes\2023\Grupo Teste\Teste Car\_Imagens\Drone\DJI_0003.MOV
            3335677673  B:\Blending Produ‡äes - Backup\Blending Produ‡äes - Tyrone Hirt - BC\Blending Produ‡äes\02. Clientes\2023\Grupo Teste\Teste Car\_Imagens\Drone\DJI_0004.MOV
            2325513829  B:\Blending Produ‡äes - Backup\Blending Produ‡äes - Tyrone Hirt - BC\Blending Produ‡äes\02. Clientes\2023\Grupo Teste\Teste Car\_Imagens\Drone\DJI_0005.MOV
            3245228768  B:\Blending Produ‡äes - Backup\Blending Produ‡äes - Tyrone Hirt - BC\Blending Produ‡äes\02. Clientes\2023\Grupo Teste\Teste Car\_Imagens\Drone\DJI_0006.MOV
             1392290    B:\Blending Produ‡äes - Backup\Blending Produ‡äes - Tyrone Hirt - BC\Blending Produ‡äes\02. Clientes\2023\Grupo Teste\Fenauto 2023\Geral\_Pr\Adobe Premiere Pro Auto-Save\Fenauto Geral 1--aa12bd8f-a378-c373-6d52-62bab88e86a6-2023-12-04_11-36-34.prproj
             1398658    B:\Blending Produ‡äes - Backup\Blending Produ‡äes - Tyrone Hirt - BC\Blending Produ‡äes\02. Clientes\2023\Grupo Teste\Fenauto 2023\Geral\_Pr\Adobe Premiere Pro Auto-Save\Fenauto Geral 1--aa12bd8f-a378-c373-6d52-62bab88e86a6-2023-12-04_12-12-44.prproj
            54138464    B:\Blending Produ‡äes - Backup\Blending Produ‡äes - Tyrone Hirt - BC\Blending Produ‡äes\02. Clientes\2023\Grupo Teste\Teste\11. Novembro\07. Teste I Fenauto Overview Final\01. Fluxo\01. Ae\07-12-2023 Teste I Fenauto Overview Final (converted
).aep
            84566896    B:\Blending Produ‡äes - Backup\Blending Produ‡äes - Tyrone Hirt - BC\Blending Produ‡äes\02. Clientes\2023\Grupo Teste\Teste\00. Identidade\01. Fluxo\01. Ae\Adobe After Effects Auto-Save\Teste I Identidade Audiovisual (converted) auto-
save 5.aep
            230815274   B:\Blending Produ‡äes - Backup\Blending Produ‡äes - Tyrone Hirt - BC\Blending Produ‡äes\02. Clientes\2023\Grupo Teste\Teste\11. Novembro\17. DLPL Cast - EP 15\05. Render\Vertical\DLPL Cast I EP 14 I Corte 1 I Vert I Financiamento I Final - v
01.mp4
            230450405   B:\Blending Produ‡äes - Backup\Blending Produ‡äes - Tyrone Hirt - BC\Blending Produ‡äes\02. Clientes\2023\Grupo Teste\Teste\11. Novembro\17. DLPL Cast - EP 15\05. Render\Vertical\DLPL Cast I EP 14 I Corte 2 I Vert I Consigna‡Æo I Final - v01
.mp4
               12200    B:\Blending Produ‡äes - Backup\Blending Produ‡äes - Tyrone Hirt - BC\Blending Produ‡äes\02. Clientes\2023\Grupo Teste\Teste Car\12. Dezembro\29. TesteCar I Carros e Repasse\01. Fluxo\01. Ae\02-01-2024 Nome.aep
           12200                  136490    B:\Blending Produ‡äes - Backup\Blending Produ‡äes - Tyrone Hirt - BC\Blending Produ‡äes\02. Clientes\2023\Grupo Teste\Teste Car\12. Dezembro\29. TesteCar I Carros e Repasse\01. Fluxo\02. Pr\02-01-2024 Nome.prproj

------------------------------------------------------------------------------

                   Total   Copiada      IgnoradaIncompatibilidade     FALHA      Extras
Diret¢rios:          3407      3302          3406         0         1           6
 Arquivos:         19705         1         19707         0         0          14
    Bytes: 2037206266068     12680 2037651251411         0         0 12312508810
N.§ de Vezes:       0:00:00   0:00:00                           0:00:00     0:00:00
   Finalizado em: quinta-feira, 4 de janeiro de 2024 01:19:19


Number of files to be copied 169

我无法通过这种方式获得正确的计数,结果是 169,而它应该是 1,因为在输出中只复制了一个文件。

如何调整我的脚本以获得预期结果?

编辑

我正在尝试另一种方法:

# Find the line containing "Arquivos:"
$filesLine = $filesToCopy | Select-String -Pattern "Arquivos:.*?(\d+)\s+(\d+)" | ForEach-Object { $_.Matches }

# Extract the second group of numbers from the line
$numberOfFilesCopied = $filesLine.Groups[2].Value

在此代码中,正则表达式Arquivos:.*?(\d+)\s+(\d+)用于搜索包含“Arquivos:”的行并捕获两组数字。然后使用 访问第二组$filesLine.Groups[2].Value。

我仍然无法得到正确的结果。

简而言之,我需要在开始复制之前计算 robocopy 将复制多少个文件。

powershell
  • 2 个回答
  • 93 Views
Martin Hope
Tyrone Hirt
Asked: 2022-11-08 15:34:00 +0800 CST

通过批处理文件在 Adob​​e Media Encoder 中打开 .mp4 文件

  • 5

我想创建一个 .bat 或 PowerShell 脚本,从 Adob​​e Media Encoder 中脚本所在的文件夹加载所有 .mp4 文件,目的是促进日常工作流程。

我在这里构建了这个脚本:

start "" "C:\Users\MyUser\Downloads\FFmpeg_Batch_AV_Converter_Portable_2.8.3_x64\FFBatch.exe" -f "%~dp0\"

它适用于大多数软件,例如我使用 FFmpeg Batch Converter 的示例,但在 Adob​​e Media Encoder 中我无法加载它。

有没有人有任何想法?

ffmpeg
  • 1 个回答
  • 25 Views
Martin Hope
Tyrone Hirt
Asked: 2022-10-27 06:41:06 +0800 CST

通过 .bat 添加到 Windows 系统路径的路径

  • 6

我想创建一个脚本来将 a 添加path到 Windows 系统Path变量中。

我搜索了很多并找到了一些可能的解决方案,但我害怕犯错误,因为我听说过一些命令可能会破坏局部Path变量,然后阻止计算机再次启动。

我想通过.bat路径包含C:\Scripts在.Pathsystem

做这个的最好方式是什么?

windows batch-file
  • 1 个回答
  • 30 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve