Link to home
Start Free TrialLog in
Avatar of FrankU09
FrankU09

asked on

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.

ASKER CERTIFIED SOLUTION
Avatar of vikas_madhusudana
vikas_madhusudana
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of FrankU09
FrankU09

ASKER

It fails during the move or copy to subfolder on local system.
what does it tell ie any error message??
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.