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 8092333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:15:42+00:00 2026-06-05T20:15:42+00:00

Heythere. I need your guys help with file renaming using a .bat file. I

  • 0

Heythere.
I need your guys help with file renaming using a .bat file.
I got multiple files that I need to be cropped after specified character number.
For exmample, I want to crop name of the files after their fifth character, this way

filename.exe > filen.exe
anothername.exe > anoth.exe
absolutelydifferentname.exe > absol.exe

And, if possible, I’d like to know how to do the opposite. I mean, leaving the certain # of characters at the end, cropping from the beginning of the filename.

Thank you.

  • 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-05T20:15:44+00:00Added an answer on June 5, 2026 at 8:15 pm

    If you want to do it in a batch file, the following should work:

    @echo off
    
    setlocal ENABLEDELAYEDEXPANSION
    
    for %%i in (<Directory name here>\*) do (
      set filename=%%~ni
      ren "%%~i" "!filename:~0,5!%%~xi"
    )
    
    endlocal
    

    If you wish to change the number of characters used to construct the final filenames, change the “5” in ren "%%~i" "!filename:~0,5!%%~xi".

    To take the last 5 characters try: ren "%%~i" "!filename:~-5!%%~xi"

    For all except the first 5 characters: ren "%%~i" "!filename:~5!%%~xi"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey there. I would really appreciate your help in creating a query that would
Hey there, I need some help with some MYSQL Joins that I really don't
Hey there, I've got a block of HTML that I'm going to be using
Hey there. I have a c# application that parses txt files and imports the
hey there guys and girls i have this code that saves json as a
hey there i have this code that should save a file from sql server
Hey there, i am trying to make a little app that will serve multiple
Hey there, I've got a project at work that may require me to load/unload
Hey there. After reading here about the Service Locator pattern, it got me thinking
hey there, i need to append to my file but it is not working,

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.