get text string from a ref.txt

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
jamesfui
Posts: 50
Joined: 27 Mar 2010 23:00

get text string from a ref.txt

#1 Post by jamesfui » 02 Apr 2010 06:29

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

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: get text string from a ref.txt

#2 Post by !k » 02 Apr 2010 07:27

Code: Select all

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

jamesfui
Posts: 50
Joined: 27 Mar 2010 23:00

Re: get text string from a ref.txt

#3 Post by jamesfui » 03 Apr 2010 05:40

hey :D

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

Post Reply