Need batch file to move multiple files to subdirectory?

Below is where I'm at trying to figure out how to move the defrag log, then copying the log file and adding the date to the new file name, then moving new file and any file with "defrag_" in the name to a subdirectory on the local system. Then I would like to copy this folder to a folder on the server. But I can't figure out the syntax of the move or whatever command I should use to accomplish this task.

defrag c: /v /f >defrag_c.log
copy defrag_c.log defrag_c_%date:~10,4%-%date:~4,2%-%date:~7,2%.log

+++++++++++++++++++++++++++++++++++++

This is what I thought I should do: defrag_c.log is located in c:\dir1\dir2

defrag c: /v /f >defrag_c.log
copy defrag_c.log \\server1\dir1\dir2\defrag_c_%date:~10,4%-%date:~4,2%-%date:~7,2%.log
or
defrag c: /v /f >defrag_c.log
copy defrag_c.log defrag_c_%date:~10,4%-%date:~4,2%-%date:~7,2%.log
copy defrag_*.log to c:\ dir1\dir2\dir3
xcopy c:\dir1\dir2\dir3 \\server1\dir1\dir2
or
move defrag_*.log to c:\dir1\dir2\dir3
xcopy c:\dir1\dir2\dir3 \\server1\dir1\dir2

Thought I tried every combination but they failed.

This batch file that can copy a folder to a specific location on a server, weekly, can help in a lot of ways to ease the routine maintenance grind. Thanks.

FrankU09Asked:
Who is Participating?
 
vikas_madhusudanaCommented:
can you please tell where you are failing if it is failing at the stage of copying to the shared location you can probably add the shared location as a drive and then do a xcopy

net use x:  \\server1\dir1\dir2
xcopy /y   c:\dir1\dir2\dir3 x:
0
 
FrankU09Author Commented:
It fails during the move or copy to subfolder on local system.
0
 
vikas_madhusudanaCommented:
what does it tell ie any error message??
0
 
FrankU09Author Commented:
The net use helped. I also noticed that running the batch file remotely using RUN > \\workstation1\c$, you get an error about UNC not supported, reverting to Windows ???. So, I used RDP to run batch and test and it all worked. Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.