move file by date last modified in a batch

October 21, 2009 at 04:17:53
Specs: Windows XP
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?


See More: move file by date last modified in a batch

Report •


#1
October 21, 2009 at 05:34:14
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 felicity

M2


Report •

#2
October 22, 2009 at 14:31:35
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.


Report •

#3
October 23, 2009 at 01:01:55
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.

Report •

Related Solutions

#4
October 24, 2009 at 04:19:45
MOVE can do an in-flight name change.


=====================================
Helping others achieve escape felicity

M2


Report •

#5
October 26, 2009 at 02:12:51
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'?


Report •


Ask Question