Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a folder structure like this:

Source

C:\Data
        Data1_timestamp
        Data2_timestamp
        Data3_timestamp
        Data4_timestamp

Destination

D:\Data
        Data1
        Data2
        Data3
        Data4

Is it possible to use robocopy to copy each source subfolder to the corresponding destination subfolder (eg. Data1_timestamp would be copied to Data1, Data2_timestamp to Data2 etc)

Destination after the copy

D:\Data
        Data1\Data1_timestamp
        Data2\Data2_timestamp
        Data3\Data3_timestamp
        Data4\Data4_timestamp
share|improve this question

1 Answer 1

up vote 0 down vote accepted

No, but you could carry this out with a combination of a for command and robocopy. Plus a bit of a substring operation using %MYVAR:~0,5%

share|improve this answer
    
I was afraid of that. Also thanks for the suggestion, but my second choice will be VBScript or PowerShell. Thanks again. –  Anonimista Sep 7 '12 at 18:51
    
Powershell will eat this up. –  Simon Catlin Sep 7 '12 at 18:55
    
Here is my first draft: gci c:\Data | %{copy $_.FullName "d:\Data\$($_.Name.Split(("_"),2)[0])"} –  Anonimista Sep 7 '12 at 19:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.