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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:01:35+00:00 2026-06-11T01:01:35+00:00

I am trying to come up with a script to do the following but

  • 0

I am trying to come up with a script to do the following but I do not have and Windows Coding experience.

I am trying to achieve the following:

I have a folder with multiple images in it and I want to rename it with a sequence like this

2012.000.value

Were value is I would like it to be able to enter a value before the script is run and the first image will be that number and then it will count up renaming that folder of images with that value.

Some images may have a file name called Original and I would like to retain that value but also insert the above sequence into the file name.

The images will be .jpg

  • 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-11T01:01:36+00:00Added an answer on June 11, 2026 at 1:01 am
    @echo off
    setlocal enabledelayedexpansion
    set count=0
    for /d %%x in (%date:~-4%.000.???) do (
      for /f "tokens=3 delims=." %%y in ("%%x") do (
        set count=%%y
        for %%z in (%%x\*.jpg) do (
          ren %%~dpnxz !count!.jpg
          set /a count=count+1
        )
      )
    )
    endlocal
    

    The above code assumes the directories will be in the format of %CurrentYear%.000.???. If you want multiple years, you’ll need different code.

    EDIT: This code will NOT output 000.jpg or 001.jpg, it will output 0.jpg or 1.jpg. The code at the bottom will deal with that.

    Also it will completely drop the original file name for ###.jpg and will work with any value. If you want the original filename preserved like so #-FileName.jpg change the ren line to:

          ren %%~dpnxz !count!-%%~nz.jpg
    

    The code will not sort the files, but will deal with them in the order that they were created in. If you want them alphabetized, then change the for %%z in (%%x\*.jpg) do ( line to:

      for /f "tokens=*" %%z in ('dir /o:n %%x\*.jpg') do (
    

    EDIT: This code will output numbers of consistent length, limited by user input.

    To use this code, you need to pass it how many characters you want the maximum number to be. So…

    IMG 2
    

    …can rename the files from 00.jpg to 99.jpg and…

    IMG 4
    

    …can rename the files from 0000.jpg to 9999.jpg.

    IMG.BAT

    @echo off
    setlocal enabledelayedexpansion
    :: Set how many characters the number can be. IE 00 = 2, 0000 = 4
    set places=%1
    set count=0
    set zeros=
    for /l %%x in (1,1,%places%) do set zeros=!zeros!0
    for /d %%x in (%date:~-4%.000.???) do (
      for /f "tokens=3 delims=." %%y in ("%%x") do (
        set count=%%y
        for %%z in (%%x\*.jpg) do (
          :: Make give !count! leading 0's if nessicary
          set count=%zeros%!count!
          :: Trim !count! down to a 4 digit number
          set count=!count:~-%places%!
          ren %%~dpnxz !count!.jpg
    
          :: Trim ALL 0's on the left to avoid calculation problems.
          set /a n=places-1
          for /l %%a in (0,1,!places!) do if "!count:~0,1!"=="0" set count=!count:~1!
          set /a count=count+1
        )
      )
    )
    endlocal
    

    I prefer this method, because Windows Explorer normally sorts files alphabetically, so this would be the file order of 1.jpg 2.jpg 3.jpg 10.jpg 20.jpg

    1.jpg
    10.jpg
    2.jpg
    20.jpg
    3.jpg
    

    But if those numbers are fixed at 3 characters width with leading 0’s, the alphabetical order of them would be:

    001.jpg
    002.jpg
    003.jpg
    010.jpg
    020.jpg
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to achieve the following, in php i have a form like this:
In trying to namespace my js/jquery code, I have come up against the following
I'm trying to come up with an algorithm that will do the following: If
I'm trying to come up with a way combine two arrays that have different
I am trying to write my watir script to grab the following data (the
Im very new to Backbone.js and have been following a couple tutorials to come
I'm trying to convert a Python script into PHP. The following 2 regular expressions
I am trying to come up with a script to check if a domain
I'm trying to remove (just replace it with ) the following String: <script type=text/javascript>
I have the following script inside a HTML page: <script> function Test(){ alert(i got

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.