Scripts Thread, script to check if folder is present in Coding and Web Development; hi guys
can any help me out with a script, I have 2 one that copys a folder to the ...
-
24th July 2009, 10:05 PM #1 script to check if folder is present
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
-
-
IDG Tech News
-
24th July 2009, 11:07 PM #2 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:
Code:
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:
- check for dir
- if it exists delete it
- 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 to Chillibear from:
ful56_uk (25th July 2009)
-
24th July 2009, 11:07 PM #3 
Originally Posted by
ful56_uk
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 to dhicks from:
ful56_uk (25th July 2009)
-
25th July 2009, 09:19 AM #4 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.
-
-
25th July 2009, 09:29 AM #5 
Originally Posted by
ful56_uk
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 Code:
on error resume next
to the code somewhere near the top
-
Thanks to sted from:
ful56_uk (25th July 2009)
-
25th July 2009, 09:58 AM #6
-
Thanks to mac_shinobi from:
ful56_uk (25th July 2009)
-
25th July 2009, 10:37 AM #7
-
-
25th July 2009, 11:45 AM #8 
Originally Posted by
ful56_uk
cheers guys sorted
no problem - Enjoy !
-
SHARE:
Similar Threads
-
By tosca925 in forum Scripts
Replies: 17
Last Post: 20th March 2010, 12:51 AM
-
By FN-GM in forum Scripts
Replies: 1
Last Post: 28th May 2008, 10:41 PM
-
By JPhillips173 in forum Scripts
Replies: 2
Last Post: 17th April 2008, 11:25 AM
-
By djones in forum Scripts
Replies: 7
Last Post: 14th March 2008, 04:50 PM
-
By tosca925 in forum How do you do....it?
Replies: 4
Last Post: 2nd October 2006, 08:15 PM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules