Computing.Net > Forums > Programming > move file by date last modified in a batch

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

move file by date last modified in a batch

Reply to Message Icon

Name: gazzwozz
Date: October 21, 2009 at 04:17:53 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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?



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: October 21, 2009 at 05:34:14 Pacific
Reply:

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


0

Response Number 2
Name: nbrane
Date: October 22, 2009 at 14:31:35 Pacific
Reply:

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.


0

Response Number 3
Name: gazzwozz
Date: October 23, 2009 at 01:01:55 Pacific
Reply:

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.


0

Response Number 4
Name: Mechanix2Go
Date: October 24, 2009 at 04:19:45 Pacific
Reply:

MOVE can do an in-flight name change.


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

M2


0

Response Number 5
Name: gazzwozz
Date: October 26, 2009 at 02:12:51 Pacific
Reply:

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'?


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon





Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: move file by date last modified in a batch

Batch File deleting files by date? www.computing.net/answers/programming/batch-file-deleting-files-by-date/15581.html

Robocopy function in a batch file www.computing.net/answers/programming/robocopy-function-in-a-batch-file/13172.html

Batch file to move file by date www.computing.net/answers/programming/batch-file-to-move-file-by-date/18832.html