Renaming a file.

September 30, 2011 at 05:20:49
Specs: Windows 7
This problem is about renaming a file that comes in everyday. The problem is that it comes with a different file name everyday. It is located inside a folder that contains other folders as well. I'm not that good with scripting so kindly help me with a scrit to rename the file.

The file name follows a sequence like .0568
tomorrow the file will be .0569
The file comes in everyday.

I want to rename it with the current date in the format Ccurrent_date.txt.
kindly help.

See More: Renaming a file.

Report •

October 20, 2011 at 15:11:21
Drop this bat file into the same directory where the files come in everyday. When you run it, it will prompt you for the file name and then take care of the rest.

@echo off


REM setting up date and time for use in new file name
set _my_datetime=%date%_%time%
set _my_datetime=%_my_datetime: =_%
set _my_datetime=%_my_datetime::=%
set _my_datetime=%_my_datetime:/=_%
set _my_datetime=%_my_datetime:.=_%

set /p oldfilename=What is the name of today's file?

ren %oldfilename% %_my_datetime%.txt

Report •

November 9, 2011 at 01:53:47
Hi Jowah..Thanks for your reply.

This works fine but i was expecting some kind of complete automation where the file name is read and renamed automatically without me having to type the name.

I want the bat file to read the file name from the location and rename it once i run it. Is that possible?

Also i just need the date and i dont want the timestamp (file should be renamed as C<mmddyy>.

Please help because i have no idea abut scripting.

Report •

November 9, 2011 at 07:06:03
If the file you want to rename, has a different filename everyday, then it's kind of a moving target. Can you send me an example scenario that walks me through a couple days? Complete with example filenames?

Report •

Related Solutions

Ask Question