Nola PowerShell fitxategi berri bat sortzeko?

new-item keyword creates a new file in the filesystem. The type of item new item creates depends on where the item is being created. Adibidez, elementu berri ere sor ditzakete erregistroko giltzak eta sarrerak erregistroan erabiltzen bada.

Type the following command in to create a new file in the current path:

ni {filename.extension}

 

The above is the alias for the following command

berri-elementua {filename.extension}

 

Adibidea

ni fun.txt

 

Parametroak ere izango dira elementu berri batekin erabil daiteke.

Honako egungo bide-fitxategi bat sortzen du, eduki batzuk:

ni -n fun.txt -p . -it f -v 'this is some silly text'

 

In the above example we have added the -name, -path and -itemtype parameters with their default values. Omitting these will generate the same result.

ni fun.txt -v 'this is some silly text'

 

If you want to overwrite an existing file use the -force or -f parameter:

ni fun.txt -v 'this is some silly text' -f

 

Sortu hainbat fitxategi uneko direktorioan:

ni -it f -p 'file.txt', 'fun.txt'

 

Sortu hainbat fitxategi c batean:/ erro eta gauza direktorioa

ni -it f -p 'c:\file.txt', 'c:\things\fun.txt'

 

Direktorioak sortzea

You can create a new directory instead of mkdir or md by using the new item command and setting the item type as directory.

ni fun -it d

 

Sortu c erro direktorioa berria:

ni -n fun -it d -p c:\

 

Sortu anitz guneak uneko bidea:

ni -it d -p 'fun', 'silly'

 

Sortu c direktorioak anitz:/ erro eta gauza direktorioa

ni -it d -p 'c:\folder', 'c:\things\fun'

 

The following table shows the parameters and it’s alias

Parameter alias Adibidea Deskribapena
-name
-n or no parameter
ni fun.txt
Specify the new item’s name
-itemtype
-it
-it d edo -it dir edo -it directory
-it f edo -it file
Specify the type of item to create. Creates file by default.
-force
-f
-f
Overwrite existing file.
-value
-v
-v 'Some file content...'
Write content of file
-path
-p
-p c:\
Path of where the new item should be created

Some commands that is useful with the ni command:

lsGet-ChildItem, lists files and directories of the current working directory. adibidez ls

gcGet-Content, view the contents of a file eg. gc fun.txt

mdmkdir, make directory eg. md mynewdirectory

rmRemove-Item, remove directory or file

 

Microsoft Docs Ofiziala