Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 358 Vote(s) - 3.63 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create directory and file in same command using PowerShell

#1
I try to create a folder and a file in one PowerShell command:
I tried:

New-Item hello\test\ (New-Item hello\test\file.txt -type file) -type directory -Force

and

New-Item file.txt (New-Item hello\test\ -type direcotry) -type file -Force

But both don't seem to work as expected.
What I want to achieve is one command to create `hello\test\file.txt`
Reply

#2
I created the directory and the file with the following code.


New-Item hello\test -type Directory ; Start-Sleep -Milliseconds 500 ; New-Item hello\test\file.txt
Reply

#3
Just provide the filepath you want, including the directory, and it will work:


New-Item -Path '.\hello\test\file.txt' -ItemType File -Force
Reply

#4
It's not case-sensitive in powershell command, so the most convenient and fastest way to create file would be - > **new-item -path . -name 'newfile.txt' -itemtype 'file'**

And for new directory, it's the same as in Linux-terminal -> **mkdir newdirectory**
Reply

#5
If you want to put the c.txt file in the b folder of the a folder, do so. `ni a/b/c.text -Force`

If you want to put two files y.txt and z.hml in x folder `ni x/y.txt, x/z.html -Force`


[1]:
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through