| 1. |
Solve : How do I delete the extension file on batch program? |
|
Answer» Hi, I have a for loop that listed some files on a directory. In the for loop, the files have been saved as variable %%f. How do I filter or remove the extention of the file. For example: %%f = abc.fm I want to remove the .fm. The result should be %%f= abc You need to study the FOR variable modifiers. Type FOR /? at the prompt. The ~n modifier is the one you need. Others will get the drive, path, extension (including DOT), size, date, etc. e.g. if the file was called abc.fm then Echo %%~nF would echo abc to the console. Also, your %z% variable which you think is going to hold the last 3 chars of the FILENAME + extension string, won't work in a loop. (Study "delayed EXPANSION".) Also that string substitution ( SET z=%%f:.fm=% ) would be a problem. For the same reason and others. Anyway you don't need these now. |
|