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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:13:32+00:00 2026-06-07T12:13:32+00:00

I basically have a setup like this: C:\Upload\A C:\Upload\B C:\Upload\C C:\Upload\D C:\Upload\E Where A

  • 0

I basically have a setup like this:

C:\Upload\A
C:\Upload\B
C:\Upload\C
C:\Upload\D
C:\Upload\E

Where A, B, C, D, E are always different (product IDs) and will always be a different amount (it won’t always be 5 sub-directories). Each of these sub-directories contains 24 images numbered numerically 01-24.

I need to create a batch file that looks at the Upload directory, gets the name of each sub-directory and appends that name to beginning of each image file contained within that sub-directory.

So, C:\Upload\A\01.jpg would become C:\Upload\A\A-O1.jpg as well as the other 23 images in each sub-directory.

The batch file needs to do the same for every sub-directory within the Upload directory.

This sounds extremely complicated to me and where I have started to try and write this, I don’t yet have anything worth sharing in this post.

Any help will be appreciated.

  • 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-07T12:13:33+00:00Added an answer on June 7, 2026 at 12:13 pm

    This will rename files in the subdirectories of “C:\Upload”

    @echo off
    for /d %%D in (C:\Upload\*) do (
      for /f "eol=: delims=" %%F in ('dir /b /a-d "%%D" ^| findstr /vbic:"%%~nD-"') do (
        ren "%%D\%%F" "%%~nD-%%F"
      )
    )
    

    I put in extra code to prevent renaming the same file twice. You should be able to safely run the script multiple times.

    If you want to recurseively rename files in each subdirectory tree, then a slight change is needed to the code.

    @echo off
    for /d /r "C:\Utils" %%D in (*) do (
      for /f "eol=: delims=" %%F in ('dir /b /a-d "%%D" ^| findstr /vbic:"%%~nD-"') do (
        ren "%%D\%%F" "%%~nD-%%F"
      )
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a View that is basically setup like this: <Grid> <ViewBox> <Grid> <ItemsControl
Ok, so I have something setup basically like this: template<typename T> void example() {
ok so basically I have a setup like this: <div id=tabs> <div id=tab_one> Something
I basically have three tables, posts, images and postimages (this simply contains the ids
I have a very simple tab switching code. Basically HTML looks like this: <ul
I have a table setup like this (simplified for example): user_id item_id click_dt Each
I have a installation setup with works like this: /exec.exe /some-command This whole setup
I have an MVC solution setup like this, with three 'projects'. Web (MVC Project,
I want to have a setup like this: <div id=block> <div class=btn>2</div> <div class=btn>1235e</div>
So we have a bunch of different processes setup in code right now. We

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.