Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8878803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:48:04+00:00 2026-06-14T19:48:04+00:00

I know that there are several posts adressing this issue already. However I can’t

  • 0

I know that there are several posts adressing this issue already. However I can’t get my little batch script to work and I am a newbie so I would be very pleased if u could help me to solve that.

I have a bunch of pdf files named with a random number and “_text” e.g. 174098_text.pdf. Now I want to rename the file such that I only have 174098.pdf left (remove _text).

Here is my latest version of my file “Rename.cmd”:

@echo off
@setlocal
REM +++++++++++++++++++++++++++++++++++++++++++++++++
REM ++++++++ Umbenennen von Dateien ++++++++++++++++
REM +++++++++++++++++++++++++++++++++++++++++++++++++


REM +++ Dateinamen und Pfad ermitteln
FOR /f "delims=" %%D in ('Dir /b %Path%\*_*.pdf') do (
FOR /f "delims=_ tokens=1-2" %%I in ('%%D') do (
    ren %%D %%I.pdf
    )
)

Endlocal

I hope you can help me and explain me what i have done wrong. Running the code it opens all the files but dosn’t rename a single one of it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:48:05+00:00Added an answer on June 14, 2026 at 7:48 pm

    /F parameter is for OPENING commands and/or get the output of a command, so when you use the second for /F you are telling the CMD to execute “%%D” file, so can’t work that.

    You can use a FOR without parameters, or a /R parameter if you need recursively a folder.

    And you don’t need to start setlocal for this job

    @echo off
    
    FOR %%# in ("C:\Folder\*.pdf") DO (
    
        :: Set the "filename.extension"
        Set "File=%%~nx#"
    
        :: Rename it
        Call Rename "%%#" "%%FILE:_TEXT=%%"
        REM Explanation:
        REM Rename "filename_text.pdf" with "Filename(_Text=NOTHING).pdf"
        REM (That removes the "_TEXT" pattern in each filename)
    )
    pause&Exit
    

    Remember, if you need recursive:

    FOR /R "C:\Folder\" %%@ in (*.pdf)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there are already several other posts for this topic, but I've tried
I know that there are some threads have a similar issue with this thread.
I know there are several posts already concerning the difference between casts and the
I know there are several other posts with solutions to this, but my current
Possible Duplicate: Objective C for Windows I know there are several posts about this
I know there have been several posts already about Sudoku-related questions, but I am
I know that there are several posts about how BAD it is to try
I know there are several other posts on this topic but they still leave
I know that there are lot's of questons on this, but all seem to
I know that there are others posts with solutions on the site but i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.