Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello,I'm hoping someone can help me with a problem. I need to have a batchfile rename a file with the current date, and move the file to a corrisponding 'month' folder. How do I get the batch to look at the filename and know what month-folder to put the file in?

Hi
A few questions.
1, What doe's 'echo %Date%' produce on your system.
2, In what format do you want the file named.
3, How are your Month Dirs named.

okay,
1. I get 'Fri 10/21/2005' on the echo %date%
2. I just need the file named for the current date, however it looks.
3. I can name the month-folders anything.
I'm hoping to have this scheduled, so I want it to be as automatic as possible.

Hi jp,
In the BAT below I set var D to a date like yours. {because my layout is different.]
You can modify the second line to:
set D=%DATE%
:: ren2MM.bat
@echo off > test1.txtset D=Fri 10/21/2005
set newNAME=%D:~10,4%%D:~4,2%%D:~7,2%
set MM=%D:~4,2%ren test1.txt %newNAME%.txt
if not exist %MM% md %MM%
move %newNAME%.txt %MM%
:: DONE
If at first you don't succeed, you're about average.M2

Thank you so much,
This is a real life-saver. Is there a book or reference out there where I can learn this? I'm sure I'll need to be writing other batch files in the future.

Thanks for letting us know that helped.
There are plenty of samples and tutorials out there; I don't have a link handy.
I find it difficult to follow others' code.
Try writing something simple ]or use an existing script] and then modify it. When you get stuck, ask for specific help.
Any question about what the script above is doing?
If at first you don't succeed, you're about average.M2

![]() |
GWBasic to VB number conv...
|
Autorun If Statement
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |