I need to copy and rename in a .bat file from comp to comp

October 22, 2012 at 13:11:18
Specs: Windows Server 2003
Ok guys i need help i tried google i tried other forums but i still cant get this fixed.

What i want to do is find index.dat file in a folder if the folder says marketing i want that file to change to marketing.dat instead of index.dat.

But i want this file sent over the network into another computer and its new directory.

Or if i can get the main script for just copy and rename a file that's fine too.


\\documents and settings\marketing\index.dat


\\other computer documents and settings\logs\marketing.dat

See More: I need to copy and rename in a .bat file from comp to comp

Report •

October 22, 2012 at 17:45:06
You can use the copy command for that:
copy /y "\\documents and settings\marketing\index.dat" "\\other computer\document and settings\logs\marketing.dat"

Doublequotes are needed because of the whitespaces in the folder names.
The /y</b suppresses yes/no on overwriting an existing file.

Report •

October 22, 2012 at 18:23:00
::====== begin script
@echo off & setlocal enabledelayedexpansion
for /f "tokens=*" %%a in ('dir /b /s "c:\documents and settings\index.dat"') do (
set x=%%~pa
set x=!x:~0,-1!
for /f "tokens=*" %%b in ("!x!") do echo move "%%a" "\\zz\documents and settings\logs\%%~nxb.dat"
::====== end script

Not sure of the scope of your search for index.dat, so i just assumed it was all subdirectories off the docs&sets. This has "safety on" ("echo" in line 5, remove for death and destruction).

Report •

Related Solutions

Ask Question