需要复制扩展名为.3GP的文件

时间:2013-03-13 17:07:41

标签: powershell windows-7

我不确定为什么这个问题已被关闭并得到了点数,但是如果没有人能够回答它,那么有人能指出我能够得到答案的方向吗?谢谢。这又是:

该文件不会与Get-ChildItemCopy-Item一起复制。以下是不运行脚本的实际powershell窗口的输出:

PS C:\> Open-Device 10.42.233.237
Connecting to device '10.42.233.237' ...


Device Name : 10.42.233.237
Device IP   : 10.42.233.237
Device Host :

Run 'Get-Variable Device*' to see variables set for the connected session.


DEVICE C:\
PS C:\> Get-ChildItem -Path "V:\WP\QM\Audio\Decode\Automated" -Filter *.3g2 | Copy-Item -Destination C:\test\MinTE
DEVICE C:\
PS C:\> putd -Path "V:\WP\QM\Audio\Decode\Automated" -Filter "*.3g2" -Destination "C:\test\MinTE"
Put-Device : A parameter cannot be found that matches parameter name 'Path'.
At line:1 char:6
+ putd -Path "V:\WP\QM\Audio\Decode\Automated" -Filter "*.3g2" -Destination "C:\te ...
+      ~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Put-Device], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.Texus.Shells.PowerShell.PutFileDeviceCmdlet

DEVICE C:\
PS C:\>

putd是Put-Device的缩写。连接到设备时,Get-ChildItem和Copy-Item不起作用。它们无法识别为cmdlet函数。以下是获得创意的完整脚本:

param(
$SourcePath, $DestinationPath
)

# Display something just as a sanity check
Write-Output "Starting Setup";

# Waits to gather input
Start-Sleep -m 1000

# Connect to device
Open-Device $env:IP_Address | out-null

# Waits to establish a connection to the device
Start-Sleep -m 2000

# Copy a files to the device
Write-Output "Copying testcases and support files..."
putd $env:source\*.mp4 C:\test\MinTE | out-null
putd $env:source\*.mp3 C:\test\MinTE | out-null
putd $env:source\*.wma C:\test\MinTE | out-null
putd $env:source\*.m4a C:\test\MinTE | out-null
putd $env:source\*.amr C:\test\MinTE | out-null
putd $env:source\*.wav C:\test\MinTE | out-null
putd $env:source\*.3g2 C:\test\MinTE | out-null
putd $env:source\*.3gp C:\test\MinTE | out-null
putd $env:source\*.xml C:\test\MinTE | out-null


# Closes Connection to device
Close-Device

# Allows space for easy reading for the user
Write-Output " "
Write-Output " "
Write-Output " "
Write-Output " "

# Tells the user the script ran successfully
Write-Output "... Setup Successful (NO REBOOT REQUIRED)"

exit;

使用批处理文件调用此脚本,当执行批处理文件命令时,用户输入两个变量。它已经过测试,适用于除“.3gp”和“.3g2”之外的所有其他文件类型。我注意到在.ps1脚本中添加“3”(使用notpad ++)时,颜色变为橙色,并在.ps1脚本中的任何位置添加“gp”(使用notpad ++)会将颜色更改为浅蓝色。这告诉我这两个可能是开关,但我不确定是什么。

此外,如果需要重现错误,这里是用于执行此脚本的批处理文件:

@echo off
::Conditions leading to errors if the batch script is not executed correctly
if "%1"=="" goto error1
if "%2"=="" goto error2

::Allows user to set the "Source Path" to copy the testcase files from
set source=%1
::Allows user to set the "Destination Path" to copy the testcase files from
set IP_Address=%2

:: Does a health check to ensure source path is valid
IF NOT EXIST "%source%" goto error3
:: Does a health check to ensure Device IP Address is valid
ping -n 1 -w 100 %IP_Address% 1>nul
if "%errorlevel%"=="1" goto error4

::Tells the user what the "Source" and "Destination" Paths are
echo Source Path = %1
echo Destination Path = %2
echo.
powershell.exe -File "BVT_AudioDecode_Automated.ps1" %1 %2 -NoProfile -NoExit


goto end
:error1
echo.
echo Error Syntax: BVT_AudioDecode_Setup.bat "Source_Path\AudioDecode_Testcase_Folder" "Device IP Address"
echo.
echo For example: BVT_AudioDecode_Setup.bat V:\WP\BVT\Audio\Decode 10.42.233.237
echo              -or-
echo              BVT_AudioDecode_Setup.bat C:\WP\BVT\Audio\Decode 10.42.233.237
echo.
echo.
goto end
:error2
echo.
echo Error Syntax: BVT_AudioDecode_Setup.bat "Source_Path\AudioDecode_Testcase_Folder"     "Device IP Address"
echo.
echo For example: BVT_AudioDecode_Setup.bat V:\WP\BVT\Audio\Decode 10.42.233.237
echo              -or-
echo              BVT_AudioDecode_Setup.bat C:\WP\BVT\Audio\Decode 10.42.233.237
echo.
echo.
goto end
:error3
echo.
echo Error: Invalid Path
echo %source%
goto end
:error4
echo.
echo Error: Invalid IP Address
echo %IP_Address%
goto end
:end

我注意到Open-DevicePutd(Put-Device的缩写)在运行get-command时具有与其他命令不同的模块名称。如果没有人认出这个清单,那么我可能来错了地方:

Cmdlet          Add-FederatedDeviceHost                            TexusCmdlets
Cmdlet          Add-FederatedEnvironment                           TexusCmdlets
Cmdlet          Add-VirtualMachine                                 TexusCmdlets
Cmdlet          CD-Device                                          TexusCmdlets
Cmdlet          Close-Device                                       TexusCmdlets
Cmdlet          Cmd-Device                                         TexusCmdlets
Cmdlet          Copy-Device                                        TexusCmdlets
Cmdlet          Create-FederatedVirtualDeviceHost                  TexusCmdlets
Cmdlet          Create-Federation                                  TexusCmdlets
Cmdlet          Debug-Device                                       TexusCmdlets
Cmdlet          Del-Device                                         TexusCmdlets
Cmdlet          Deploy-Device                                      TexusCmdlets
Cmdlet          Dir-Device                                         TexusCmdlets
Cmdlet          Exec-Device                                        TexusCmdlets
Cmdlet          Filter-Result                                      TexusCmdlets
Cmdlet          Get-ChildPrimitive                                 TexusCmdlets
Cmdlet          Get-Device                                         TexusCmdlets
Cmdlet          Get-ResultSummary                                  TexusCmdlets
Cmdlet          Get-SuiteName                                      TexusCmdlets
Cmdlet          Get-TaskOutputPath                                 TexusCmdlets
Cmdlet          Get-VirtualMachineNames                            TexusCmdlets
Cmdlet          Kill-Device                                        TexusCmdlets
Cmdlet          Merge-Reports                                      TexusCmdlets
Cmdlet          MkDir-Device                                       TexusCmdlets
Cmdlet          Mount-VirtualDisk                                  TexusCmdlets
Cmdlet          Move-Device                                        TexusCmdlets
Cmdlet          Open-Device                                        TexusCmdlets
Cmdlet          Put-Device                                         TexusCmdlets
Cmdlet          Reg-Device                                         TexusCmdlets
Cmdlet          Remove-FederatedDeviceHost                         TexusCmdlets
Cmdlet          Remove-VirtualMachine                              TexusCmdlets
Cmdlet          RmDir-Device                                       TexusCmdlets
Cmdlet          Set-VirtualMachine                                 TexusCmdlets
Cmdlet          Show-Result                                        TexusCmdlets
Cmdlet          Start-VirtualMachine                               TexusCmdlets
Cmdlet          Stop-VirtualMachine                                TexusCmdlets
Cmdlet          Test-Device                                        TexusCmdlets
Cmdlet          TList-Device                                       TexusCmdlets
Cmdlet          Type-Device                                        TexusCmdlets
Cmdlet          Unmount-VirtualDisk                                TexusCmdlets
Cmdlet          Validate-FederatedDeviceHost                       TexusCmdlets

1 个答案:

答案 0 :(得分:1)

我终于找到了答案!

PS U:\> get-help put-device -full

Do you want to run Update-Help?
The Update-Help cmdlet downloads the newest Help files for Windows PowerShell modules and installs them on your
computer. For more details, see the help topic at http://go.microsoft.com/fwlink ?LinkId=210614.
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y

NAME
    Put-Device

SYNOPSIS
    Copies one or more files from the host machine to the connected device.

SYNTAX
    Put-Device [-Source] [<string>] [[-Destination] [<string>]] [<CommonParameters>]


DESCRIPTION
    The Put-Device cmdlet copies one or more files from the host machine to the connected device.
    Absolute paths are used as-is and relative paths are treated relative to the
    current working directory, either on the device or the host.


PARAMETERS
    -Source [<string>]
        The path of the source file(s) on the host ('*' and '?' wildcards are supported).

        Required?                    true
        Position?                    0
        Default value
        Accept pipeline input?
        Accept wildcard characters?

    -Destination [<string>]
        The path of the destination file or directory on the device.
        If omitted, the current working directory on the device will be used.

        Required?                    false
        Position?                    1
        Default value
        Accept pipeline input?
        Accept wildcard characters?

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, see
        about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

INPUTS

OUTPUTS


RELATED LINKS

获取此信息后,这是解决问题的正确命令:

putd -Source "$env:source\*.3gp" -Destination "C:\test\MinTE" | out-null

如果有人可以从中吸取教训,我会留下这个。