+ Post New Thread
Results 1 to 8 of 8
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 ...
  1. #1
    ful56_uk's Avatar
    Join Date
    Mar 2008
    Location
    Essex
    Posts
    423
    Thank Post
    91
    Thanked 18 Times in 17 Posts
    Rep Power
    12

    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

  2. IDG Tech News

  3. #2

    Join Date
    Feb 2009
    Posts
    95
    Thank Post
    3
    Thanked 33 Times in 32 Posts
    Rep Power
    12
    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:
    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.

  4. Thanks to Chillibear from:

    ful56_uk (25th July 2009)

  5. #3

    dhicks's Avatar
    Join Date
    Aug 2005
    Location
    Knightsbridge
    Posts
    4,707
    Thank Post
    968
    Thanked 598 Times in 521 Posts
    Rep Power
    198
    Quote Originally Posted by ful56_uk View Post
    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

  6. Thanks to dhicks from:

    ful56_uk (25th July 2009)

  7. #4
    ful56_uk's Avatar
    Join Date
    Mar 2008
    Location
    Essex
    Posts
    423
    Thank Post
    91
    Thanked 18 Times in 17 Posts
    Rep Power
    12
    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.

  8. #5


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    3,493
    Thank Post
    134
    Thanked 473 Times in 412 Posts
    Rep Power
    149
    Quote Originally Posted by ful56_uk View Post
    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

  9. Thanks to sted from:

    ful56_uk (25th July 2009)

  10. #6

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    7,026
    Thank Post
    1,088
    Thanked 641 Times in 598 Posts
    Rep Power
    209

  11. Thanks to mac_shinobi from:

    ful56_uk (25th July 2009)

  12. #7
    ful56_uk's Avatar
    Join Date
    Mar 2008
    Location
    Essex
    Posts
    423
    Thank Post
    91
    Thanked 18 Times in 17 Posts
    Rep Power
    12
    cheers guys sorted

  13. #8

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    7,026
    Thank Post
    1,088
    Thanked 641 Times in 598 Posts
    Rep Power
    209
    Quote Originally Posted by ful56_uk View Post
    cheers guys sorted
    no problem - Enjoy !

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 17
    Last Post: 20th March 2010, 12:51 AM
  2. Double check this script please
    By FN-GM in forum Scripts
    Replies: 1
    Last Post: 28th May 2008, 10:41 PM
  3. Replies: 2
    Last Post: 17th April 2008, 11:25 AM
  4. Run script if specific hardware present
    By djones in forum Scripts
    Replies: 7
    Last Post: 14th March 2008, 04:50 PM
  5. VB Script ti check for folder and then copy contents to PC
    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
  •