Jump to content

How to move all files from a folder for a user to a centralized folder


Recommended Posts

Hello,



I'm curious if there is a batch file that can be made to move the contents that are setup like this....



I'm having to redo a TS cluster and I'd like to make a batch file script that can be executed that moves the contents of say 'jsmith's local desktop profile @ \\NGTTS1\users\jsmith to a centralized folder on our roaming desktop profile server that saves all of the files for the desktops @ \\NGTFS1\users\jsmith.



The problem I have is no matter what I tell users to save there files to our Y drive that is a folder that is synced across all 6 of our TS servers, users still store files on there desktops, so as you can imagine if one day they are on one server, then next day they could be on another and there files aren't the same.... hence the reason why I want to move all there files to the centralized server so when I redo the profiles from scratch on the TS server in the farm they suck files from the core server and have all of the files they are used to having....



Now I know I can do this with a MOVE command I've just never done one to this exact.



Hopefully someone knows the command to move all the contents of one folder on one server to the folder on a different server. I've already got the bulk of the coding done of the .bat script I just don't know this move command:



would it be this:



move \\NGTTS1\users\jsmith *.* \\NGTFS1\users\jsmith



any help would be appreciated, I'm sure this is a easy command to do!




Also what I'd like to do if force the copy of the files even if the some of the files are duplicates and just copy over them or skip them, just not sure how to do this....



This is what I got so far for coding:



@echo off

color 0A

title Moving Local Profile folder to Centralized Profile Folder on Core Server.


:start

echo Welcome, %USERNAME%

echo What would you like to do?

echo.

echo 1. Moving Local Profile folder to Centralized Profile Folder on Core Server

echo.

echo 0. Quit

echo.


set /p choice="Enter your choice: "

if "%choice%"=="1" goto Move-user-profiles

echo.

if "%choice%"=="0" exit

echo Invalid choice: %choice%

echo.

pause

cls

goto start



:Move-user-profiles

echo.

set /p profile="Enter user profile: "

move "\\NGTTS1\users\%profile%" *.* "\\NGTFS1\users\%profile%"

echo moving files from local profile folder to FS1 profile server, stand-by...

echo.

goto cancel-special


:cancel-special

set /p cancel="Type cancel to stop action: "

if not "%cancel%"=="cancel" exit

cls

echo Action is cancelled.

echo.


pause

exit

Edited by deathmage
Link to comment
Share on other sites


Here is a VBS script that will move only files that do not exists on the other computer and reports the results in a self closing messagebox. There is no user input and you can not cancel

Note

This make the folder where the script resides for the object

Fso.GetFolder(".").Files

To use another folder just put a path in between the quotes example

Fso.GetFolder("Drive:\Folder\SomeName").Files

This is to make sure the VBS script does not get moved to the other folder

If Not LCase(Obj.Path) = LCase(WScript.ScriptFullName) Then

This make sure that files does not get moved to the other folder if it exists

If Fso.FileExists("\\HOMEBETAVISTA\VistaHomeBeta\" & Obj.Name) Then

'-> This code is property of Gunsmokingman and Or Jake1Eye and you must have his permission to use.'-> This is only posted as example code and meant only to used as such.Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")Dim Obj, Var For Each Obj In Fso.GetFolder(".").Files  If Not LCase(Obj.Path) = LCase(WScript.ScriptFullName) Then    If Fso.FileExists("\\HOMEBETAVISTA\VistaHomeBeta\" & Obj.Name) Then    Var = Var & "File Exists : \\HOMEBETAVISTA\VistaHomeBeta\" & Obj.Name & vbCrLf    Else     Var = Var & "Move File   : \\HOMEBETAVISTA\VistaHomeBeta\" & Obj.Name & vbCrLf    Fso.MoveFile Obj.Path, "\\HOMEBETAVISTA\VistaHomeBeta\" & Obj.Name   End If   End If  Next CreateObject("Wscript.Shell").Popup "Script Completed" & vbCrLf & Var ,30,"Move Completed",4128
post-5386-0-53740000-1389602232_thumb.pn
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...