+ 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
    554
    Thank Post
    105
    Thanked 23 Times in 21 Posts
    Rep Power
    17

    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. #2

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

  3. Thanks to Chillibear from:

    ful56_uk (25th July 2009)

  4. #3

    dhicks's Avatar
    Join Date
    Aug 2005
    Location
    Knightsbridge
    Posts
    5,622
    Thank Post
    1,240
    Thanked 777 Times in 674 Posts
    Rep Power
    235
    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

  5. Thanks to dhicks from:

    ful56_uk (25th July 2009)

  6. #4
    ful56_uk's Avatar
    Join Date
    Mar 2008
    Location
    Essex
    Posts
    554
    Thank Post
    105
    Thanked 23 Times in 21 Posts
    Rep Power
    17
    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.

  7. #5


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,578
    Thank Post
    228
    Thanked 853 Times in 732 Posts
    Rep Power
    294
    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

  8. Thanks to sted from:

    ful56_uk (25th July 2009)

  9. #6

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,710
    Thank Post
    3,246
    Thanked 1,048 Times in 970 Posts
    Rep Power
    364

  10. Thanks to mac_shinobi from:

    ful56_uk (25th July 2009)

  11. #7
    ful56_uk's Avatar
    Join Date
    Mar 2008
    Location
    Essex
    Posts
    554
    Thank Post
    105
    Thanked 23 Times in 21 Posts
    Rep Power
    17
    cheers guys sorted

  12. #8

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,710
    Thank Post
    3,246
    Thanked 1,048 Times in 970 Posts
    Rep Power
    364
    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: 19th March 2010, 11:51 PM
  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, 03: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
  •