-3

新项目类型文件名/ init .py

我有文件夹“NAME”。命令“new-item”不起作用。我应该怎么办?

4

2 回答 2

1

你应该试试 : New-Item -Path .\NAME -Name init.py -Type file

如果您位于目录 NAME 中,请仅使用点,或输入路径(来自上述目录或完整路径)。

ps:powershell的错误输出也可以。

于 2021-04-17T14:34:24.917 回答
0

这个...

new-item -type file NAME/init.py

...根本不是有效的语法。有关 cmdlet 和使用的详细信息,请参阅 PowerShell 帮助文件。具体一点,不要猜测或强迫 PowerShell 为您猜测。

例如:

Get-ChildItem -Path 'D:/Temp' -Filter 'init.py'
# Results
<#
No results
#>

New-Item -Path 'D:\Temp' -Name 'init.py' -ItemType file -WhatIf
# Results
<#
What if: Performing the operation "Create File" on target "Destination: D:\Temp\init.py".
#>

New-Item -Path 'D:\Temp' -Name 'init.py' -ItemType file
# Results
<#
    Directory: D:\Temp


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         18-Apr-21     20:45              0 init.py
#>

(Get-ChildItem -Path 'D:/Temp' -Filter 'init.py').FullName
# Results
<#
D:\Temp\init.py
#>


# Get specifics for a module, cmdlet, or function
(Get-Command -Name New-Item).Parameters
(Get-Command -Name New-Item).Parameters.Keys
Get-help -Name New-Item -Examples
# Results
<#
 New-Item -Path .\TestFolder -ItemType Directory
 New-Item -Path .\TestFolder\TestFile.txt -ItemType File
 New-Item -Path .\TestFolder -ItemType Directory -Force
 Get-ChildItem .\TestFolder\
 New-Item ./TestFile.txt -ItemType File -Value 'This is just a test file'

#>
Get-Help -Name New-Item -Detailed
Get-help -Name New-Item -Full
Get-help -Name New-Item -Online
于 2021-04-19T03:48:21.090 回答