2

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

file01
file02

instead of

file01.pdf
file02.pdf

whenever I invoke the following batch.

echo off
for %%x in (*.pdf) do echo %%x
pause
Second Person Shooter
  • 14,188
  • 21
  • 90
  • 165
  • 1
    possible duplicate of [Batch: Remove file extension](http://stackoverflow.com/questions/3215501/batch-remove-file-extension) – Cees Timmerman Oct 07 '14 at 14:10

2 Answers2

6

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

Community
  • 1
  • 1
ember
  • 365
  • 5
  • 11
0

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.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Shawni
  • 1