Search a local file and copy to a share

September 11, 2009 at 07:21:56
Specs: Windows XP
Hi there, Could anyone help me to write a batch file, basically i need to search a_*.xls file on c:\ or d:\ file, if exist, then copy to \\server1\share folder...

Thanks!!!


See More: Search a local file and copy to a share

Report •


#1
September 11, 2009 at 07:50:32
@echo off & setLocal EnableDELAYedExpansion

for %%d in (c d) do (
for /f "tokens=* delims= " %%a in ('dir/s/b %%d:\*.xls') do (
copy %%a "\\server1\share folder"
)
)


=====================================
Helping others achieve escape felicity

M2


Report •

#2
September 11, 2009 at 08:03:39
Hi there,

I really appreciate for the help! but when i tried running it.. i got "file not found".. and I checked the file is there...


echo off & setLocal EnableDELAYedExpansion

for %%d in (c d) do (
for /f "tokens=* delims= " %%a in ('dir/s/b %%d:\a_*.xls') do (
copy %%a "\\server1\share
)
)


Report •

#3
September 11, 2009 at 08:32:12
I don't know why. It found the xls files on my c: drive. [There aren't any on d:.]


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
September 11, 2009 at 08:47:04
Hi, Thanks for taking the time to help me! yeah, for some reason, it works perfectly only if a_*.xls exists on c:, not d: drive. The file just can't be found on the d:\ drive...


Report •

#5
September 11, 2009 at 08:49:10
Does it have the hidden or system bit set?


=====================================
Helping others achieve escape felicity

M2


Report •

#6
September 11, 2009 at 09:58:32
Hi there, you know what.. it's working now.... none of the attributes were checked... YOU ARE ROCK!!! thanks again for helping me!!!


Report •


Ask Question