- How to Create Files and Folders without Name
- Create Files Without Name
- Steps to Create File Without Name
- Steps to Create More than One Files Without Name
- Create Folder Without Name
- Steps to Create Folder without Name
- Create More than one Folders Without Name
- Create unique file name Windows batch
- 10 Answers 10
- How do I manually create a file with a . (dot) prefix in Windows? For example, .htaccess
- 15 Answers 15
- How to create an empty file at the command line in Windows?
- 33 Answers 33
- FltGetFileNameInformation function (fltkernel.h)
- Syntax
- Parameters
- Return value
- Remarks
How to Create Files and Folders without Name
Create Files Without Name
You can easily create files without name in windows 7. To create files without name in windows 7, you have to press Alt+0160 instead of naming the file.
Steps to Create File Without Name
Here are the steps involved to create files without name in window 7. Here are the steps, used to create a text files without name:
- Open any folder
- Inside the folder, press right click
- Go to New ->Text Document
- A new text file will be created, containing New Text Document as its default name
- Now instead of writing the name of the file, just press Alt key and type 0160 from the right side of the keyboard.
- Don’t release Alt key before typing 0160
- After typing, 0160, just release your hand from the keyboard
- You will watch New Text Document is replaced with blank (no name)
- Now press ENTER
- Now you have a text file without name
Here is the snapshots of the text file without name:
Steps to Create More than One Files Without Name
Here are the steps to create more than one files without name. To create more than one files without name inside the same folder in window 7, follow these steps. Here we are continuing to create 2nd file, then 3rd file and so on. The steps to create first file without name are the same as above provided. Here we are going to continue to create 2nd file without name:
- Again press right click
- Go to New ->Text Document
- Again you will watch, a new text file is created, having its default name as New Text Document
- Now again, instead of writing the name of the file
- Just press Alt key and then type 0160 from the right side of the keyboard
- Now release you hand from the keyboard
- You will again watch, that New Text Document is replaced with no name
- Now to create 2nd file without name, again press Alt and type 0160
- Now again release your hand from the keyboard
- You will watch there is one more space is created
- Now press Enter, you have another file without name
Here is the snapshot, showing the two text files without name in window 7:
Now let’s look at these short step to create files without name in window 7 operating system. Here there are three steps to create 1 text file without name:
Now you will have 1 text file without name. Now here are the steps to create 2 text files without name:
- Press Right Click ->New ->Text Document
- Press ALT + 0160
- Release hand from keyboard
- Press ALT + 0160
- Press ENTER
Now you will have 2 text files without name. Now here are the steps to create 3 text files without name:
- Press Right Click ->New ->Text Document
- Press ALT + 0160
- Release hand from keyboard
- Press ALT + 0160
- Release hand from keyboard
- Press ALT + 0160
- Press ENTER
Now you will have 3 text files without name. You can follow the above given pattern to create a large number of text files as you want. Here is a sample snapshots having 10 text files without name:
To create large number of files without name, you can follow copy and paste operation as mentioned in these steps:
- Do the above steps to create first text file without name
- Now select the first file
- Press F2 key
- Copy the space (name of the file, that is 1 space)
- And follow the steps, that is used to create first text file
- Do the paste operation to write the first space
- And follow the steps to create one more space to create the 2nd file without name (or having name with two space)
- Now again select the second file
- Press F2 key
- Copy the spaces (name of the 2nd file, that is 2 spaces)
- And follow the steps , that is used to create the first file
- Do the paste operation to write the 2 spaces
- And follow the steps to create one more space, to create total three space to create the third file without name
- And so on
Create Folder Without Name
It is easy to create folders without name in window 7. To create folder without name, follow the same steps as provided above.
Steps to Create Folder without Name
Here are the steps involved to create folder without name:
Now you will have a folder without name. Here is the snapshot of the folder without name:
Create More than one Folders Without Name
To create more than one folders without name, follow these steps:
- Press Right Click ->New ->Folder
- Press Alt + 0160
- Release your hand
- Again press Right Click ->New ->Folder
- Press Alt + 0160
- Release your hand
- Press ENTER
Now you will have two folders without name. To create a large number of folders without name, follow these steps:
- Press Right Click ->New ->Folder
- Press Alt + 0160
- Release your hand
- Again press Right Click ->New ->Folder
- Press Alt + 0160
- Release your hand
- Again press Right Click ->New ->Folder
- Press Alt + 0160
- Release your hand
- and so on
- Press ENTER
Here is the snapshots having 10 folders without name:
Create unique file name Windows batch
I have seen many posts about creating a unique filename from the naive %TIME% to the plausible (but insufficient) %RANDOM%. Using wmic os get localdatetime is much better, but it can still fail on multiple CPU/core machines. The following script will eventually fail when run in 5+ shells on a multple core machine.
Does anyone have a reliable way to create a unique file name in a shell script?
10 Answers 10
Any system that relies on a random number can theoretically fail, even one using a GUID. But the world seems to have accepted that GUIDs are good enough. I’ve seen code posted somewhere that uses CSCRIPT JScript to generate a GUID.
There are other ways:
First I will assume that you are trying to create a unique temporary file. Since the file will be deleted once your process ends, all you must do is establish an exclusive lock on a resource whose name is a derivative of your temp file name. (actually I go in reverse — the temp name is derived from the locked resource name).
Redirection establishes an exclusive lock on the output file, so I simply derive a name from the time (with 0.01 second preciscion), and attempt to lock a file with that name in the user’s temp folder. If that fails than I loop back and try again until I succeed. Once I have success, I am guaranteed to have sole ownership of that lock, and all derivitives (unless someone intentionally breaks the system).
Once my process terminates, the lock will be released, and a temp file with the same name could be reused later on. But the script normally deletes the temp file upon termination.
Looping due to name collision should be rare unless you are really stressing your system. If so, you can reduce the chance of looping by a factor of 10 if you use WMIC OS GET LOCALDATETIME instead of %TIME% .
If you are looking for a persistent unique name, then the problem is a bit more difficult, since you cannot maintain the lock indefinitely. For this case I recommend the WMIC OS LocalDateTime approach, coupled with two checks for name collision.
The first check simply verifies the file does not already exist. But this is a race condition — two processes could make the check at the same time. The second check creates the file (empty) and establishes a temporary exclusive lock on it. The trick is to make sure that the lock is maintained for a period of time that is longer than it takes for another process to check if the file exists. I’m lazy, so I simply use TIMEOUT to establish a 1 second wait — way more than should be necessary.
The :getUniqueFile routine expects three arguments — a base name, an extension, and the variable name where the result is to be stored. The base name can include drive and path information. Any path information must be valid, otherwise the routine will enter an infinite loop. That issue could be fixed.
The above should be guaranteed to return a new unique file name for the given path. There is a lot of room for optimization to establish some command to execute during the lock check that takes «long enough» but not «too long»
How do I manually create a file with a . (dot) prefix in Windows? For example, .htaccess
I want to create a .htaccess file manually and discovered it seems impossible through the Windows UI. I get a «you must type a filename.» message. There has to be a way to create files with . as a prefix in Windows.
Can this be done manually?
15 Answers 15
If you start Notepad and then File -> Save As -> Write .htaccess and choose «All Files» as the type — then it will create the .htaccess file for you.
Windows 7, 8 & 10
This is dead easy since Windows 7. In File Explorer, right click anywhere and create a new file. Type the new filename as .something. (notice the appended period) and press enter twice, job done.
So instead of being prompted with
You will instead be prompted with
If you change a file name extension, the file might become unusable.
Note: If you’re having issues then please ensure you have «file name extensions» visible, you can activate this under the «View» menu in File Explorer. Also, this method works for folders too.
Within Notepad select File > Save As.
File name: «.whatever you want» (with the leading dot)
You can do it in Explorer (in Windows 7) by adding a period at the end of the filename:
.whatever you want.
Windows will automatically remove the trailing dot when you validate.
Go to command prompt, cd to the appropriate folder and type:
After confirmation dialog the file will be created and you will be editing it directly. If you just want to create an empty file, try
You could also use Command Prompt with move : move x.extension .extension
You can do this in any program other than Explorer , e.g. Notepad , cmd.exe etc.
You just can’t do it in Explorer, and Raymond Chen has offered an explanation as to why not.
Just type .htaccess. as filename. Notice the dot at the end of htaccess. This will change in Windows to .htaccess without a dot at the end.
Even if you don’t have any third party editor (Notepad++ etc.) then also you can create files with dot as prefix.
To create .htaccess file, first create htaccess.txt file with Context Menu > New Text Document .
Then press Alt + D (Windows 7) and Ctrl + C to copy the path from the Address bar of Windows Explorer.
Then go to command line and type code as below to rename your file:
Now you have a blank .htaccess without opening it in any editor.
How to create an empty file at the command line in Windows?
How to create an empty file at the DOS/Windows command-line?
but it always displays that a file was copied.
Is there any other method in the standard cmd?
It should be a method that does not require the touch command from Cygwin or any other nonstandard commands. The command needs to run from a script so keystrokes cannot be used.
33 Answers 33
In the same spirit, Samuel suggests in the comments:
the shortest one I use is basically the one by Nomad:
It does give an error:
But this error is on stderr. And > only redirects stdout, where nothing have been produced.
Hence the creation of an empty file.
The error message can be disregarded here. Or, as in Rain’s answer, redirected to NUL :
(Original answer, November 2009)
( echo «» would actually put «» in the file! And echo without the ‘.’ would put » Command ECHO activated » in the file. )
Note: the resulting file is not empty but includes a return line sequence: 2 bytes.
This discussion points to a true batch solution for a real empty file:
The » » pipes a nul response to the set/p command, which will cause the variable used to remain unchanged. As usual with set/p , the string to the right of the equal sign is displayed as a prompt with no CRLF.
Since here the «string to the right of the equal sign» is empty. the result is an empty file.
The difference with cd. > filename (which is mentioned in Patrick Cuff’s answer and does also produce a 0-byte-length file) is that this «bit of redirection» (the trick) can be used to echo lines without any CR:
The dir command should indicate the file size as 11 bytes: » helloworld! «.
FltGetFileNameInformation function (fltkernel.h)
The FltGetFileNameInformation routine returns name information for a file or directory.
Syntax
Parameters
[in] Pointer to a FLT_CALLBACK_DATA structure, which is the callback data structure for the I/O operation. This parameter is required and cannot be NULL.
[in] A FLT_FILE_NAME_OPTIONS value containing flags that specify the format of the name information to be returned, as well as the query method that the Filter Manager is to use. (Additional flags can be used by name provider minifilter drivers to specify name query options.) This parameter is required and cannot be NULL.
The following are the file name format flag values. Only one of the following flags can be specified. For an explanation of these formats, see FLT_FILE_NAME_INFORMATION.
Name Format Flag Value | Meaning |
---|---|
FLT_FILE_NAME_NORMALIZED | The FileNameInformation parameter receives the address of a structure containing the normalized name for the file. |
FLT_FILE_NAME_OPENED | The FileNameInformation parameter receives the address of a structure containing the name that was used when the file was opened. |
FLT_FILE_NAME_SHORT | The FileNameInformation parameter receives the address of a structure containing the short (8.3) name for the file. The short name consists of up to 8 characters, followed immediately by a period and up to 3 more characters. The short name for a file does not include the volume name, directory path, or stream name. Not valid in the pre-create path. |
Following are the file name query method flag values. Only one of the following flags can be specified.
Query Method Flag Value | Meaning |
---|---|
FLT_FILE_NAME_QUERY_DEFAULT | If it is not currently safe to query the file system for the file name, FltGetFileNameInformation does nothing. Otherwise, FltGetFileNameInformation queries the Filter Manager’s name cache for the file name information. If the name is not found in the cache, FltGetFileNameInformation queries the file system and caches the result. |
FLT_FILE_NAME_QUERY_CACHE_ONLY | FltGetFileNameInformation queries the Filter Manager’s name cache for the file name information. FltGetFileNameInformation does not query the file system. |
FLT_FILE_NAME_QUERY_FILESYSTEM_ONLY | FltGetFileNameInformation queries the file system for the file name information. FltGetFileNameInformation does not query the Filter Manager’s name cache, and does not cache the result of the file system query. |
FLT_FILE_NAME_QUERY_ALWAYS_ALLOW_CACHE_LOOKUP | FltGetFileNameInformation queries the Filter Manager’s name cache for the file name information. If the name is not found in the cache, and it is currently safe to do so, FltGetFileNameInformation queries the file system for the file name information and caches the result. |
Name provider minifilters use the following flags to specify the properties of file name operations.
Name Provider Flag Value | Meaning |
---|---|
FLT_FILE_NAME_REQUEST_FROM_CURRENT_PROVIDER | A name provider minifilter can use this flag to specify that a name query request should be redirected to itself (the name provider minifilter) rather than being satisfied by the name providers lower in the stack. |
FLT_FILE_NAME_DO_NOT_CACHE | This flag denotes that the name retrieved from this query should not be cached. Name provider minifilters use this flag as they perform intermediate queries to generate a name. |
FLT_FILE_NAME_ALLOW_QUERY_ON_REPARSE | A name provider minifilter can use this flag to specify that it is safe to query the name in the post-create path even if STATUS_REPARSE was returned. It is the caller’s responsibility to ensure that the FileObject->FileName field was not changed. Do not use this flag with mount points or symbolic link reparse points. |
[out] Pointer to a caller-allocated variable that receives the address of a system-allocated FLT_FILE_NAME_INFORMATION structure containing the file name information. FltGetFileNameInformation allocates this structure from paged pool. This parameter is required and cannot be NULL.
Return value
If the name information is successfully returned, FltGetFileNameInformation returns STATUS_SUCCESS. Otherwise, it returns an appropriate NTSTATUS value such as one of the following:
Return code | Description |
---|---|
STATUS_FLT_INVALID_NAME_REQUEST | |
STATUS_INSUFFICIENT_RESOURCES | FltGetFileNameInformation encountered a pool allocation failure. This is an error code. |
STATUS_INVALID_PARAMETER | Returned when an invalid parameter is passed, such as one of the following:
STATUS_INVALID_PARAMETER is an error code. |
STATUS_FLT_NAME_CACHE_MISS | The file name information is not found in the name cache and NameOptions includes FLT_FILE_NAME_QUERY_CACHE_ONLY. The file name information is not found in the name cache when NameOptions includes FLT_FILE_NAME_QUERY_ALWAYS_ALLOW_CACHE_LOOKUP and the file name information cannot be queried from the file system. An additional call to FltGetFileNameInformation with FLT_FILE_NAME_QUERY_FILESYSTEM_ONLY set in NameOptions may return the file name information. |
STATUS_NOT_SAME_DEVICE | The file being queried during pre-create is on a different volume than its parent directory. This error is returned for normalized name queries, where the file was a junction or symlink that resolved to a different volume. |
STATUS_ACCESS_DENIED | If the user opened the file by file ID but does not have traverse privileges for the entire path, FltGetFileNameInformation fails with this return value. STATUS_ACCESS_DENIED is an error code. The file is a system file with all access denied. RemarksFltGetFileNameInformation returns the requested name information for the file or directory that is the target of the operation described by CallbackData, in the specified format. The file or directory does not need to be opened yet by the file system. For a pre-create operation, if the CallbackData->Iopb->OperationFlags member contains the SL_OPEN_TARGET_DIRECTORY bitwise flag, FltGetFileNameInformation returns the name of the containing (parent) directory for the given file. This name is the actual path that the create operation opens. To parse the contents of the FLT_FILE_NAME_INFORMATION structure returned by FltGetFileNameInformation, call FltParseFileNameInformation. (For more information about file name formats, see FLT_FILE_NAME_INFORMATION.) After a successful call to FltGetFileNameInformation, the caller is responsible for releasing the pointer returned in the FileNameInformation parameter when the pointer is no longer needed. The caller does this by calling FltReleaseFileNameInformation. The caller must not modify the contents of the structure returned in the FileNameInformation parameter because this structure is cached by the Filter Manager so that all minifilter drivers can use it. If FltGetFileNameInformation is called in the preoperation callback routine for a create operation to retrieve the opened name, FltGetFileNameInformation succeeds even if the path to the file being opened does not exist on the volume. If FltGetFileNameInformation is called in the preoperation callback routine for a create operation to retrieve the normalized name, FltGetFileNameInformation succeeds even if the final component of the path to the file being opened does not exist on the volume. Starting in Windows 10, you cannot query normalized file names on a remote volume because the Server Message Block (SMB) Protocol does not support queries for normalized paths. In create, hard-link, and rename operations, file name tunneling can cause the final component in normalized file name information that a minifilter driver retrieves in a preoperation callback routine to be invalidated. If a minifilter driver retrieves normalized file name information in a preoperation callback (PFLT_PRE_OPERATION_CALLBACK) routine by calling a routine such as FltGetFileNameInformation, it must call FltGetTunneledName from its postoperation callback (PFLT_POST_OPERATION_CALLBACK) routine to retrieve the correct file name information for the file. For Windows 8.1 and earlier, FltGetFileNameInformation can include a stream type only when called from a filter’s pre-create callback. To distinguish between a file’s default stream and metadata streams, this call should be made in the pre-create operation. The resulting stream type will remain valid across the lifetime of the file. Prior to Windows 8, Filter Manager obtained the normalized name for a file or directory by collecting the name information for each component of the file path. This required multiple queries to the file system to compile the complete path. Starting with Windows 8, local file systems support the FileNormalizedNameInformation file information class and only a single query is necessary to obtain the normalized name. Remote file systems may not support the FileNormalizedNameInformation file information class. When this is the case, a query for each component of the file path is still required to assemble the normalized name. Under certain network conditions, a full name query can require a significant amount of time to complete. For more information about normalized file name information, see FLT_FILE_NAME_INFORMATION. File name tunneling affects only create, hard-link, and rename operations in this way. It does not affect other I/O operations, such as read and write. The following paired operations can cause the file name name to be tunneled: |