Reputation: 1
new-item -type file NAME/init.py
I have folder "NAME". The command "new-item" doesn't work. What should I do?
Upvotes: -3
Views: 1958
Reputation: 16086
This...
new-item -type file NAME/init.py
... is simply not valid syntax. See the PowerShell help files for details on the cmdlet and use. Be specific, don't guess or force PowerShell to guess for you.
For Example:
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
Upvotes: 0
Reputation: 49
You should try :
New-Item -Path .\NAME -Name init.py -Type file
Use only the dot if you are located in your directory NAME, or enter the path (from the above directory or the full path).
ps: having the error output of powershell could be nice too.
Upvotes: 1