Click here for important information about

Batch File to Copy File

August 4, 2010 at 07:36:34
Specs: Windows XP
I am writing a batch file that will find the current desktop background in XP and copy the image file to a different location. So far I have managed to get it find the filename in the Custom.theme file, trim it down to just the file path and assign that path to a varialble. Now for some reason the copy command can't find the file defined in the variable. Typing the file path in Start Run works fine. I am not sure what I am doing wrong here.


for /F "delims=" %%a in ('findstr /b /l "Wallpaper=" "C:\Documents and Settings\%USERNAME%\Application Data\Microsoft\Windows\Themes\Custom.theme" ') do set str=%%a

set str=%str:~10,50%

for /l %%a in (1,1,31) do if "!str:~-1!"==" " set str=!str:~0,-1!


XCOPY %str% "F:\NewComputer"

See More: Batch File to Copy File

August 4, 2010 at 09:58:52
I don't have the path/file you have.

[M$ is always moving stuff to create the impression that each version is an 'improvement'. LOL]

Moving right along...

I don't see where you're headed with the findstr and other gyrations, nor why you're using xcopy.

It may help to post the contents of the Custom.theme file.

I would:


@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir/b/s c:\my.bmp') do (
set src=%%a

copy "!src!" d:\dest

Helping others achieve escape felicity


Report •
Related Solutions

Ask Question