How to distinguish/target extension-less files? (Command Batch, Windows 10) - TagMerge
2How to distinguish/target extension-less files? (Command Batch, Windows 10)How to distinguish/target extension-less files? (Command Batch, Windows 10)

How to distinguish/target extension-less files? (Command Batch, Windows 10)

Asked 1 years ago
0
2 answers

If you only want to view or process files with an extension, use this syntax: dir /b /a-d [path] | findstr /m /l "." Only files containing a dot will be displayed. You can add this to the for statement to get the output to a processable variable. Of course, you must add an escape character before the pipe character in the for sentence. However, to perform the operation in the subdirectories as well, it is best to use the for sentence, as a dot may appear in the folder name. like this: for /f "tokens=*" %d in ('dir /s /b /ad') do @dir /b /a-d "%d" | findstr /m /l "." To do the opposite (showing only files without an extension) simply change the findstr /m parameter to findstr /v.

Source: link

0

If you are only want to rename a single file and extension, you can specify the full file name and file extension as shown.
rename Test1.txt Test1.html
Like using the rename command, you can also use the move command to rename a file as shown.
move Test1.txt Test1.html
If you want to rename the extensions without keeping the original file, you can also use a command similar to the following example.
rename *.shn *.wav
The above command will change the extension of all files from .shn to .wav
ren *.* *.newextension
Use the following command at the Windows command line or within a batch file.
xcopy *.shn *.wav

Source: link

Recent Questions on windows

    Programming Languages