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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:04:34+00:00 2026-05-11T20:04:34+00:00

What would the Windows command line script be to rename a folder from the

  • 0

What would the Windows command line script be to rename a folder from the current month, to the current month – 3, using the format YYYY-MM ?

e.g.:

c:\myfiles\myFolder\

should become:

c:\myfiles\2009-01\
  • 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-05-11T20:04:34+00:00Added an answer on May 11, 2026 at 8:04 pm

    For my locale, I need something different.

    Also you need to deal with single-digit months, I suppose.

    setlocal
    @REM example:  Thu 06-11-2009
    set stamp=%DATE%
    
    @REM get the year
    set year=%stamp:~10,4%
    @REM example: 2009
    
    @REM get the month
    set month=%stamp:~4,2%
    @REM example:  06
    
    @REM subtract 3 months
    set /a month=%month%-3
    @REM example:  3
    
    @REM test if negative (we rolled back beyond January 1st)
    if %month% LSS 1  (
      set /a month=%month%+12
      @REM example: 8
      set /a year=%year%-1
      @REM example: 2008
    )
    
    @REM prepend with zero for single-digit month numbers
    set month=0%month%
    
    @REM take last 2 digits of THAT
    set month=%month:~-2%
    
    set newFolder=%year%-%month%
    
    @REM move %1 %newFolder%
    endlocal
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 107k
  • Answers 107k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You'd usually see this in the implementation of an ==… May 11, 2026 at 9:04 pm
  • Editorial Team
    Editorial Team added an answer From a MonoDevelop blog post: There were several long time… May 11, 2026 at 9:04 pm
  • Editorial Team
    Editorial Team added an answer It took me a while to find it but I… May 11, 2026 at 9:04 pm

Related Questions

I have a large set of files, some of which contain special characters in
I'm about to be forced to write a script to download some number of
(Bear with me, I promise this gets to shebang and windows.) I have about
I'm adding functionality to an existing Java application that's already been deployed extensively. (So
We have an R Server (R is a programming language used in statistical analysis)

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.