Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi All
I have a file that is created each day and always dumps as "Output", renamed as follows:
@echo off
for /f "tokens=1-4 delims=/ " %%d in ("%date%") do rename "C:\output.txt" output_%%d_%%e_%%f.txt
What I now need to do is to move the renamed file to a new location. Is there a method of moving files in a '.bat' based on today's date? Maybe by last modified date?

If you use the same naming convention for the folder I guess you could:
move output_%%d_%%e_%%f.txt %%d_%%e_%%f
=====================================
Helping others achieve escape felicityM2

what about substit. "move" for "rename", like:
for /f "tokens=1-4 delims=/ " %%d in ("%date%") do move "C:\output.txt" TESTDIR\output_%%d_%%e_%%f.txt
that's assuming the directory stays constant, and is not
also changing according to date.

it's just occurred to me that if I swap the job around (i.e. move the file first and then rename it) this is a lot easier! Thanks for your help chaps.

MOVE can do an in-flight name change.
=====================================
Helping others achieve escape felicityM2

OK guys, back to the drawing board, there are in fact three files that need moving - two of which are output from other in house software that need moving on a daily basis. They to have the date string applied to naming convention of the file.
Is there any way to specify moving a file by attribute 'last modified'?

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |