Announcement

Collapse
No announcement yet.

Need script for moving folders and deleting existing ones

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need script for moving folders and deleting existing ones

    I'm desperate here. I really really need a script that does the following:

    c:\"folder A" have subfolders called 210007, 210212 etc.

    I want the script to move all the subfolders to c:\"folder B", but first check if there are any subfolders in "folder B" with the same names, if so delete them. And then move the subfolders.

    Anyone here that can make this script for me?
    The script have to be able to run in a windows environment.

    A HUGE thanks to anyone that can create a script for me.

  • #2
    Re: Need script for moving folders and deleting existing ones

    Use Robocopy. It can do exactly what you need. You can save the commands as a batch file.

    Comment


    • #3
      Re: Need script for moving folders and deleting existing ones

      Originally posted by joeqwerty View Post
      Use Robocopy. It can do exactly what you need. You can save the commands as a batch file.
      Thank you so much.
      You are a lifesaver!

      Comment


      • #4
        Re: Need script for moving folders and deleting existing ones

        Yes, use Robocoppy, it is a very useful command line tool - good to get acquaintance with and match its capabilities with batch commands.

        alternatively, a batch w/out using Robocopy would be something like:
        Code:
        @echo off
        Set "sourcefolder=c:\folder1234"
        Set "destinationfolder=c:\folder5678"
        
        If Exist %sourcefolder% (
         For /F %%* In ('Dir /b /aD "%sourcefolder%" 2^>nul') do (
             If Exist "%destinationfolder%\%%*" (
               RD /S /Q "%destinationfolder%\%%*")
             Move /y "%sourcefolder%\%%*" "%destinationfolder%\")
        ) Else (echo.Source folder could not be found)
        
        
        :end of batch
        echo.&echo.finished!&pause>nul
        \Rems

        This posting is provided "AS IS" with no warranties, and confers no rights.

        __________________

        ** Remember to give credit where credit's due **
        and leave Reputation Points for meaningful posts

        Comment

        Working...
        X