Jump to content

Recommended Posts

Posted

hi guys

 

can any help me out with a script, I have 2 one that copys a folder to the local c and one that deletes it

 

what i want is one script that will first check if the folder is there, if it is delete it and the copy a new one from a network share. if the folder is not there then copy the folder form the network share.

 

can any one help?

 

thanks

 

mark

Posted

Any particular language/OS?

 

If you wanted to do it with a batch file, you can check to see if a directory exists (c:\temp in this example) with something like following:

IF NOT EXIST C:\TEMP\NUL GOTO NODIR
REM - stuff to do if dir exists
exit
:NODIR
REM - stuff to do if dir does not exist
exit

 

However if I understand what you want the sequence is:

  1. check for dir
  2. if it exists delete it
  3. copy dir from LAN

So in any case you copy the new folder down, so just add a command to delete it first (rmdir /s /q should do it), if it's not there then you'll probably get an error back, but I doubt it'd break things. Apologies if I've misunderstood.

  • Thanks 1
Posted
what i want is one script that will first check if the folder is there, if it is delete it and the copy a new one from a network share. if the folder is not there then copy the folder form the network share.

 

In a particular language? Here's a simple batch file:

 

@echo off

if exist c:\myFolder erase /S /Q c:\myFolder

copy n:\myFolder c:\

 

--

David Hicks

  • Thanks 1
Posted

Vb really

 

I have a vb script to delete the folder. Problem is because I don't know enough. When the folder isn't there is it gives me a error on screen. What I really want is for it to contiune without error.

 

 

@ chillibear. That is the sequnce. Check if folder is there, if it is delete it, if not move on to copying folder from network share to c.

Posted
Vb really

 

I have a vb script to delete the folder. Problem is because I don't know enough. When the folder isn't there is it gives me a error on screen. What I really want is for it to contiune without error.

 

 

@ chillibear. That is the sequnce. Check if folder is there, if it is delete it, if not move on to copying folder from network share to c.

 

add

on error resume next

to the code somewhere near the top

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...