?
Solved

batch file - rename with system date -1

Posted on 2003-03-05
4
Medium Priority
?
1,754 Views
Last Modified: 2008-02-01
I need to look for a file every day that system date -1

example file (system date is 2003-03-05) I am looking for is:

pos.20030304.c1315 and I want to rename the file to pos20030304.txt

thanks
0
Comment
Question by:jmason218
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Expert Comment

by:Moliere
ID: 8073851
For batch renaming, I use a program called The Rename. It is freeware and can be obtained at http://www.herve-thouzard.com/therename.phtml

Otherwise, you could do it with VBScript.
0
 

Author Comment

by:jmason218
ID: 8073934
Thanks but I would like to run just a simple batch and not add in another program.
0
 
LVL 1

Accepted Solution

by:
anetwork earned 150 total points
ID: 8075097
Your have two problems:
1) Cannot do maths in a script (eg count=count-1)
2) If the day is 1, and you subtract one, the date could ne 31, 30, 29 (in a leap year) or 28.  Likeise for the month 01, etc.

Solution: run a batch today that itself creates a bacth file that records todays date.  Then, run this new batch file tomorrow.  Something like this:


for /f "tokens=1,2,3,4 delims=/ " %%i in ('date /t') do SysDate=%%l%%j%%k
echo set %sysdate-1% > %sysdate%.bat
call sysdate-1.bat
for %%a in (*.%sysdate-1%.*) do ren %%a %sysdate-1%.txt
ren sysdate.bat sysdate-1.bat

NB this records dates in UK format; adjust variables etc for US format.

Script needs checks to stop it renaming sysdate.bat too soon - but now you have the variable SysDate that should be easy.  If not, let us know.

Phew!

0
 

Author Comment

by:jmason218
ID: 8151759
Thanks for the Help...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction How to create multiboot configuration with XP\Vista and Windows 7 on it? And most important question - how to do this correctly so not to have any kind of nightmares we get when system gets screwed? First of all one should realize t…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question