开发者

Removing file extension in a for-loop variable

How to remove the extension (including the dot) such that I get

file01
file02

instead of

file01.pdf
file02.pdf

whenever 开发者_如何学PythonI invoke the following batch.

echo off
for %%x in (*.pdf) do echo %%x
pause


I found this link for you for some good ideas: Batch: Remove file extension. But based on that, you can just do this:

@echo off
for %%x in (*.pdf) do  echo %%~nx

All best, ember


I know this is late but since I needed the same solution and had an issue with the solution above, I figured it may help someone else.

for %%f in (*.pdf) do ren %%f, %%~nf

Basically this solution checks for all the .pdf extensions and removes them using the rename command.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜