如何使用命令行打开此 GoPro 文件夹?(Windows 10)

如何使用命令行打开此 GoPro 文件夹?(Windows 10)

当我通过 USB 插入 GoPro 相机时,我必须单击四个文件夹才能到达包含视频文件的文件夹:

This PC\HERO8 BLACK\GoPro MTP Client Disk Volume\DCIM\100GOPRO

100GOPRO是视频文件所在的位置。我尝试创建此文件夹的快捷方式,但 Windows 不允许我这样做 - 当我尝试将图标从地址栏拖到桌面时,没有创建快捷方式。

我创建了一个批处理文件,告诉资源管理器打开该文件夹,但路径以“此电脑”开头,而不是驱动器号。我在批处理文件中尝试了以下操作:

explorer "This PC\HERO8 BLACK\GoPro MTP Client Disk Volume\DCIM\100GOPRO"

不起作用,这只会打开我的文档(找不到路径时的默认文件夹)。

当我在 Windows 的设备管理器中查看时,此 GoPro 被归类为“MTP USB 设备”。驱动程序是最新的。

这个限制还意味着我无法使用批处理文件从设备复制视频文件,如果可能的话,这将非常方便。

除非父文件夹“此电脑”有一些神奇的代码,否则这似乎无法完成?

提前致谢。

编辑:我尝试了这个但它也不起作用:

explorer "shell:mycomputerfolder\HERO8 BLACK\GoPro MTP Client Disk Volume\DCIM\100GOPRO"

我可以做的是右键单击HERO8 BLACK“此电脑”中的图标并创建快捷方式,它说无法在那里创建快捷方式,所以我想将它放在桌面上 - 是的 - 然后我在桌面上有一个该设备的快捷方式,但我无法编辑该快捷方式属性中的路径以将其余路径添加到它(它显示为灰色)否则它会起作用。

我知道我正在询问如何在命令行上打开文件夹和通过快捷方式打开文件夹,但无论我使用哪种方式都没关系,我只想运行一次并打开最终的文件夹。如果是在命令行上,那就更好了,因为这样我就可以使用它来创建一个命令,将文件复制到运行批处理文件的文件夹中。

答案1

以下是我不使用 AutoIt 时如何做到的。这是一种更简洁的方法,只要设置设备名称和路径,即可一键解决:

将其放入批处理文件中:

:: Put the device name from "This PC" here inside the double quotes:
set DEVICE_NAME="HERO8 BLACK"

:: Put the device folder path (the part after the device name in "This PC") here inside the double quotes:
set DEVICE_FOLDER_PATH="GoPro MTP Client Disk Volume\DCIM\100GOPRO"

:: Copy MP4 files from Device
start /wait /min Powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0CFD.ps1' -deviceName '%DEVICE_NAME%' -deviceFolder '%DEVICE_FOLDER_PATH%' -targetFolder '%CD%' -filter '(.mp4)$'"

创建一个名为的 Powershell 脚本CFD.ps1并将其输入:

# Windows Powershell Script to copy a set of files (based on a filter) from a folder
# on a MTP device (e.g. Android device) to a folder on a computer, using the Windows Shell.
# By Daiyan Yingyu, 19 March 2018, based on the (non-working) script found here:
#   https://www.pstips.net/access-file-system-against-mtp-connection.html
# as referenced here:
#   https://powershell.org/forums/topic/powershell-mtp-connections/
#
# This Powershell script is provided 'as-is', without any express or implied warranty.
# In no event will the author be held liable for any damages arising from the use of this script.
#
# Please note that used 'as-is' this script will COPY files from you device.
# If you want to move files instead, you can replace the CopyHere function call with "MoveHere" instead.
# WARNING: The files will be DELETED from the source (the device) and MOVED to the computer.
# But once again, the author can take no responsibility for the use, or misuse, of this script.</em>
#
param([string]$deviceName,[string]$deviceFolder,[string]$targetFolder,[string]$filter='(.jpg)|(.mp4)$')
 
function Get-ShellProxy
{
    if( -not $global:ShellProxy)
    {
        $global:ShellProxy = new-object -com Shell.Application
    }
    $global:ShellProxy
}
 
function Get-Device
{
    param($deviceName)
    $shell = Get-ShellProxy
    # 17 (0x11) = ssfDRIVES from the ShellSpecialFolderConstants (https://msdn.microsoft.com/en-us/library/windows/desktop/bb774096(v=vs.85).aspx)
    # => "My Computer" — the virtual folder that contains everything on the local computer: storage devices, printers, and Control Panel.
    # This folder can also contain mapped network drives.
    $shellItem = $shell.NameSpace(17).self
    $device = $shellItem.GetFolder.items() | where { $_.name -eq $deviceName }
    return $device
}
 
function Get-SubFolder
{
    param($parent,[string]$path)
    $pathParts = @( $path.Split([system.io.path]::DirectorySeparatorChar) )
    $current = $parent
    foreach ($pathPart in $pathParts)
    {
        if ($pathPart)
        {
            $current = $current.GetFolder.items() | where { $_.Name -eq $pathPart }
        }
    }
    return $current
}
 
$deviceFolderPath = $deviceFolder
$destinationFolderPath = $targetFolder
# Optionally add additional sub-folders to the destination path, such as one based on date
 
$device = Get-Device -deviceName $deviceName
$folder = Get-SubFolder -parent $device -path $deviceFolderPath
 
$items = @( $folder.GetFolder.items() | where { $_.Name -match $filter } )
if ($items)
{
    $totalItems = $items.count
    if ($totalItems -gt 0)
    {
        # If destination path doesn't exist, create it only if we have some items to move
        if (-not (test-path $destinationFolderPath) )
        {
            $created = new-item -itemtype directory -path $destinationFolderPath
        }
 
        Write-Verbose "Processing Path : $deviceName\$deviceFolderPath"
        Write-Verbose "Moving to : $destinationFolderPath"
 
        $shell = Get-ShellProxy
        $destinationFolder = $shell.Namespace($destinationFolderPath).self
        $count = 0;
        foreach ($item in $items)
        {
            $fileName = $item.Name
 
            ++$count
            $percent = [int](($count * 100) / $totalItems)
            Write-Progress -Activity "Processing Files in $deviceName\$deviceFolderPath" `
                -status "Processing File ${count} / ${totalItems} (${percent}%)" `
                -CurrentOperation $fileName `
                -PercentComplete $percent
 
            # Check the target file doesn't exist:
            $targetFilePath = join-path -path $destinationFolderPath -childPath $fileName
            if (test-path -path $targetFilePath)
            {
                write-error "Destination file exists - file not moved:`n`t$targetFilePath"
            }
            else
            {
                $destinationFolder.GetFolder.CopyHere($item)
                if (test-path -path $targetFilePath)
                {
                    # Optionally do something with the file, such as modify the name (e.g. removed device-added prefix, etc.)
                }
                else
                {
                    write-error "Failed to move file to destination:`n`t$targetFilePath"
                }
            }
        }
    }
}

只要在第一个文件(批处理文件)的顶部正确设置了 2 个变量并将其放在CFD.ps1批处理文件旁边,就可以将设备的 MP4 文件复制到与批处理文件和 ps1 脚本相同的文件夹中。

也可以同时复制 jpg 和 mp4 文件,或者仅复制 jpg 文件,但这需要在批处理文件中使用略有不同的命令:

复制 JPG 和 MP4 文件:

start /wait /min Powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0CFD.ps1' -deviceName '%DEVICE_NAME%' -deviceFolder '%DEVICE_FOLDER_PATH%' -targetFolder '%CD%\Files' -filter '(.jpg)|(.mp4)$'"

仅复制 JPG 文件:

start /wait /min Powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0CFD.ps1' -deviceName '%DEVICE_NAME%' -deviceFolder '%DEVICE_FOLDER_PATH%' -targetFolder '%CD%\Files' -filter '(.jpg)$'"

原始 ps1 脚本实际上从设备中移动了文件,这不是上述脚本的意图(它复制)。

要移动文件,请更改CopyHereMoveHereps1 脚本的第 98 行。

还有什么……我不知道。看看这个 ps1 脚本对于这么简单的任务来说有多长!都是因为该设备没有驱动器号。

使用此功能,您可以将其应用于任何 MTP 设备,只要您在批处理文件的开头输入正确的设备名称和路径即可。ps1 脚本可以保持不变。

相关内容