How can i create an empty file using a batch command? [duplicate] - windows

This question already has answers here:
Create an empty file on the commandline in windows (like the linux touch command)
(27 answers)
Closed 5 years ago.
So far my project is all about creating files for an imaginary game and I have to create files (and files within files), first, I have to ask them what version they want, and then the batch will create new files on my computer.
I just want to know what is the command to create new files, no need for other info.

Yes, you can.
type nul > your_file.txt
It is already resolved here
Windows equivalent of 'touch' (i.e. the node.js way to create an index.html).

Related

How to "touch" a file in raw CMD without a touch command? [duplicate]

This question already has answers here:
Create an empty file on the commandline in windows (like the linux touch command)
(27 answers)
Closed 1 year ago.
At the good old Windows command prompt, I want to ensure a file exists and create it if it doesn't. I don't want to download any additional utilities (like touch) to accomplish this.
Here is one-liner solution:
As an example, I want to ensure a file named App_Offline.htm exists in my website root, but without overwriting that file if it already exists. This is the native DOS command I successfully used with append:
(echo empty > nul) >> App_Offline.htm
Note the word empty can be any text you want because it is simply a dummy placeholder piped through nul and is lost; therefore no value is effectively appended to an existing file, and if a file doesn't already exist then it is created empty.
This solution did not update the Modified time stamp of the existing file.

Run batch file located in sub directory with another batch file [duplicate]

This question already has answers here:
Get current batchfile directory
(4 answers)
Closed 1 year ago.
So I know you think I should do something like: start C:\parentfolder\subfolder\batchfile.bat
or something along those but I was wonder if there was like a way to reference the sub directory without using it's actual name? Since the batch files will be generated by another batch file.
Don't ask why I need it to be generated I'd much rather it not but couldn't find any other way.
You have to cd into a subdirectory and then run start start.bat. That should run another batch file. To go into a relative subdirectory, run the command cd foldername. You have to make sure you are currently in the parent directory.

Get path to the user home directory on Windows in PowerShell? [duplicate]

This question already has answers here:
Getting home directory?
(2 answers)
Closed 2 years ago.
I am trying to get the path to the current user's home directory (e.g. C:\Users\User1) while respecting different localizations of Windows (which have a different name for the Users folder).
I have seen solutions in Batch, but isn't there a clean way of doing it in PowerShell?
Use the environment variable $env:USERPROFILE.
For example:
cd "$env:USERPROFILE\Downloads"
will take you to the user's Downloads folder (given that it's named "Downloads").]

How to overwrite file without deleting existing file? [duplicate]

This question already has answers here:
Is bash > redirection atomic?
(3 answers)
In Bash, how to not create the redirect output file once the command fails
(3 answers)
Node.js fs.writeFile() empties the file
(3 answers)
Closed 4 years ago.
I have a node_exporter web server running which serves files from a directory. These files have host metrics at a particular point-in-time. I have a daemon running that scrapes metrics from other exporters every 15 seconds and writes to this directory. When it writes files, I think it removes the existing file and writes a new file. Because of this, once in a while, for a split second node_exporter serves no metrics from an exporter. How do I make sure the previous metrics exist until the new metrics are written and there's no empty/duplicate metrics?
write to a temporary file in the same directory
when done, rename the temporary file to the result file
mv tempfile outputfile

How to stop ".DS_store" file creation why its create [duplicate]

This question already has answers here:
How to stop creating .DS_Store on Mac? [closed]
(8 answers)
Closed 8 years ago.
In my computer each folder has .DS_store file. If I delete it after several days its automatically creates .DS_store file. How do I stop it.
Open Terminal.
Execute this command:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
Either restart the computer or log out and back in to the user account.
for more informations:
https://support.apple.com/en-us/HT208209
I don't believe you can- DS_Store is generated every time a folder is accessed in the Finder. So, if you really don't want it (or need to get rid of it for an archive or something similar), delete it using the command prompt and don't access the folder again with the Finder.

Resources