Example: I have a file: FILENAME.EXT and would like to extract FILENAME without the .EXT I want to be able to use the extensionless filename for a command which only accepts filenames without its extensions. I have a utility called BCHECK which accepts as its argument a filename with no extensions. Using BCHECK *. does not work because all the files have .DAT or .IDX extensions. These files are constantly being renamed, thus I need to provide BCHECK with the new filenames without having to manually enter them.
views:
63answers:
3For DOS batch files you can look at parameters here. For example, the following command displays the filename without extension for the 0 parameter, which is the name of the batch file.
echo %~n0
UPDATE:
Here's an example that can be added to a batch file.
FOR %%f IN (*.dat) DO bcheck -y %%~nf
This command will run bcheck -y BASENAME
for each file with a .dat
extension in the current directory. The command is a for loop that contains a parameter %%f
. The %%f
parameter contains the file's full name. For each file matching *.dat
, it will run the command after the DO keyword. The %%~nf
indicates to to use the basename (~n
) from the parameter (%%f
).
So I have looked at several DOS batch utilities and tricks in MGD and other DOS-related websites, but none of these work!.. can anyone think of a clever way for executing a utility which takes as its argument basenames of all files within a directory?..
CAVEAT: Remember, this is native DOS 6.22, not the Windows cmd.exe command interpreter, so %~nx won't work, these are extension in the FOR batch command which are not available in DOS 6.22..