Page 1 of 1

get text string from a ref.txt

Posted: 02 Apr 2010 06:29
by jamesfui
hi dostips batch scripters,
do anyone know how to insert the text string from another file ex. ref.txt?
for example,

ref.txt
-----------content--------------
"c:\reports\source\"

----------end content-----------


copy.bat
------------code start-----------
@echo off
CD " ref.txt " <- get the upper 'text string' from ref.txt & insert it here!!
copy *.doc "d:\destination\"

-----------code end-------------

so that whenever i change the location of the source in ref.txt,
the copy.bat still works as my new location!!

thanks !! :D

Re: get text string from a ref.txt

Posted: 02 Apr 2010 07:27
by !k

Code: Select all

@echo off
for /f "usebackq delims=" %%a in ("ref.txt") do cd /d "%%a"
copy *.doc "d:\destination"

Re: get text string from a ref.txt

Posted: 03 Apr 2010 05:40
by jamesfui
hey :D

thanks!!! this script works just fine...!!! :D