[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Need batch file to move multiple files to subdirectory?

Posted on 2010-01-06
4
Medium Priority
?
459 Views
Last Modified: 2012-05-08
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.

0
Comment
Question by:FrankU09
  • 2
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
vikas_madhusudana earned 1500 total points
ID: 26192076
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
 

Author Comment

by:FrankU09
ID: 26192252
It fails during the move or copy to subfolder on local system.
0
 
LVL 7

Expert Comment

by:vikas_madhusudana
ID: 26192295
what does it tell ie any error message??
0
 

Author Closing Comment

by:FrankU09
ID: 31673566
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question