Simple del copy/ren and move bat

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
thmpr52
Posts: 1
Joined: 16 May 2012 15:03

Simple del copy/ren and move bat

#1 Post by thmpr52 » 16 May 2012 15:22

Trying to setup a scheduled task to run this bat file that basically does the following:

del \\server name\share\file.xml
copy e:\folder\*.xml \\server name\share\file.xml
move e:\folder\*.xml e:\folder\backup

seems simple but apparently my inaccurate use of commands prevents this from working :cry:

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Simple del copy/ren and move bat

#2 Post by foxidrive » 16 May 2012 19:03

thmpr52 wrote:Trying to setup a scheduled task to run this bat file that basically does the following:

del \\server name\share\file.xml
copy e:\folder\*.xml \\server name\share\file.xml
move e:\folder\*.xml e:\folder\backup

seems simple but apparently my inaccurate use of commands prevents this from working :cry:


If you have long filename and foldernames with spaces etc then you will need the quoted lines below.
Other than that it looks ok: you can remove the 'if exist filename ' portions if the files will always be there, but they won't hurt it if you leave them in.

Be aware that a scheduled task uses the system account by default and may not have permissions to access network resources.


if exist "e:\folder\*.xml" (
if exist "\\server name\share\file.xml" del "\\server name\share\file.xml"
copy "e:\folder\*.xml" "\\server name\share\file.xml"
move "e:\folder\*.xml" "e:\folder\backup"
)

Post Reply