General discussion

Locked

Batch file to move files based on date

By hardeec ·
We have a process that outputs multiple files throughout the day and we would like to have a batch file run at night to create a directory with the current date (format of the date isn't crucial). Then move the files made that day to the recently created directory. I have found old dos batch files but none work in Windows Server 2k3. Any help

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by hardeec In reply to Batch file to move files ...

Please, anyone?

Collapse -

by rbmrf In reply to Batch file to move files ...

makedir c:\backupdir\%date%

this will create a directory with the current date

the rest i think is easy move c:\* c:\backupdir\%date%

i use this for running backups at nigth, and my directories are with the date of the day that the script runs

Collapse -

by hardeec In reply to

I wish it was that simple. %date% outputs "Tue 06/14/05". It can't make a directory or copy files with "Tue 06/14/05". I either need a batch command that edits %date% down to a usable date or some other method. Any other ideas?

Collapse -

by TonytheTiger In reply to Batch file to move files ...

(Between the '===' is all on one line)
===
for /f "tokens=1-4 delims=/ " %%i in ('date /t') do set todaydir=%%l%%j%%k
===
then change to the destination drive and

md %todaydir%

look at help for date options for XCOPY. Move does not have a date function, but Xcopy does, you can then delete the files you just xcopied by going to the destination drive and directory and

for %%f in (*.*) do del \%%f

Collapse -

by hardeec In reply to

bless you. It works! Where is this type of batch programing listed on microsoft's site? I am going to close the question so just send me a private message.

Collapse -

by hardeec In reply to Batch file to move files ...

This question was closed by the author

Collapse -

Please send me this batch file

by mahesh2506 In reply to Batch file to move files ...
Back to Windows Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums