Solved

Moving report files from One folder to another without overwriting,Including Subfolders

Posted on 2016-10-04
2
25 Views
Last Modified: 2016-10-23
Hi is it possible to move files from One folder to another Using Robocopy ,
I want to move only Rpt files  without overwriting if there exists  File with same name,  Also files from all subfolders in the directory also shoud moved.

I have done so far Below.

@echo off
    setlocal enableextensions enabledelayedexpansion

    rem configure directories
    set "source=E:\Source /S"
    set "target=E:\Destination"

    rem move non existing files to target
    call :doMove    

    rem if we still have files
    if exist "%source%\*.rpt" (

        rem generate a timestamp
        set timestamp=_%date:/=%_%time::=%
        set timestamp=!timestamp:,=!

        rem rename the remaining files with timestamp
        ren "%source%\*.rpt" "*.!timestamp!.rpt"

        rem and move the remainig files to target
        call :doMove
    )

    endlocal
    exit /b

:doMove
    robocopy "%source%" "%target%" "*.rpt" /fp /njh /njs /ndl /xc /xn /xo /xx /mov
    goto :EOF


Result
-----------
It moves all file from the path, But it does nt move files from the subfolders inside the path.
Please help me.
0
Comment
Question by:Mith Mithu
  • 2
2 Comments
 
LVL 24

Accepted Solution

by:
NVIT earned 500 total points (awarded by participants)
ID: 41828767
This looks strange....
set "source=E:\Source /S"

shouldn't it be
set "source=E:\Source"

and /S is the robocopy subfolders switch?

robocopy "%source%" "%target%" "*.rpt" /fp /njh /njs /ndl /xc /xn /xo /xx /mov /S
0
 
LVL 24

Expert Comment

by:NVIT
ID: 41855867
Question answered
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question