script to move files from one computer to another on network

i forgot how so need help
how do i take and pass a list of computers to a script to take and pull files from that computer back to a local computer here
i need to pass it login creds

something like
copy \\[from this location]\directory to office\destination

but need to run it against a list of networked computers. thanks!
bbimisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bbimisAuthor Commented:
@echo off
setlocal
set directory='server directory i need to pull from'
set TargetFolder='home office directory'
for /f "usebackq" %%a in ("computerlist.txt") do (
	net use \\%%a\IPC$ "securepassword" /user:administrator
	for %%f in (%FileList%) do (
		copy "%~dp0%%~f" "\\%%a\%TargetFolder::=$%"
	)
	net use \\%%a\IPC$ /delete
) 

Open in new window

0
bbimisAuthor Commented:
i need something along those lines but confused.
thanks!
0
oBdACommented:
Plain batch; just create a text file with one computer per line, and set the variables at the beginning according to your environment.
@echo off
setlocal
set ComputerList=C:\Temp\test.txt
set User=SomeDomain\SomeUser
REM Keep the double quotes around the password:
set Password="TopSecret"
set Source=C$\Temp
REM a folder with the source computer name will be created automatically under this folder
set Target=C:\Temp\Destination
for /f %%a in ('type "%ComputerList%"') do (
	call :Process %%~a
)
echo Done.

goto :eof
:Process
echo Connecting to %1 ...
net.exe use \\%1\IPC$ %Password% /User:%User% >NUL
if errorlevel 1 (goto :eof)
robocopy.exe "\\%1\%Source%" "%Target%\%1" *.* /r:0
net.exe use \\%1\IPC$ /delete /y >NUL
goto :eof

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Josef Al-ChacarSystems AdministratorCommented:
I like robocopy it moves the folders/subfolders and keeps permissions.


EX:
robocopy C:\FOLDER \\DESTINATION\SHARENAME\SUBFOLDER

Thats the basic command.

Josef
0
bbimisAuthor Commented:
well can i not have something like this in a bat file

@echo off
set local
set ComputerList=C:\TEMP\COMPUTERLIST.txt

for /f %%a in ('type "%ComputerList%"') do
   net use b: \\%ComputerList%\[pathtofiles here]
   net use z: \\server\shareddir
   
   xcopy b:\*.* z:\
   
   net use b: /delete
   net use z: /delete
   echo moved files for location: %%a
)
echo done

Open in new window

0
oBdACommented:
That's basically what my script does. The main question is: do you really want the same target folder for all computers? This means files with the same name will constantly be overwritten.
0
bbimisAuthor Commented:
got it thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.