for example, i always need to use the move command (move.bat) the destination i always set it to an output folder, but the Source always need to change...
:: All Document move command
CD "refer from ref.txt" :: <- source
move *.doc "c:\output\document\"
Is there a way to set the CD: current directory in this (move.bat) always refer from a text document (ref.txt) located in the desktop?
if possible, plz do not use the set /p var=
but use the CD instead.. cz mostly the full path is quite long to input it manually
thanks
set current directory (CD) in a bat from another ref.txt
Moderator: DosItHelp
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Re: set current directory (CD) in a bat from another ref.txt
Do you mean that ref.txt already contains the path that you're interested in?
Code: Select all
for /f "usebackq tokens=" %%a in ("c:\path to ref\ref.txt") do cd /d "%%~a"
Re: set current directory (CD) in a bat from another ref.txt
to make it more clear:
i have (move.bat) which Locate in c:\batch\records\move.bat
i would like to move all *.doc from c:\temp\doc\file1.doc file2.doc ...etc
to destination path for example, c:\permanent\destination\
so the destination path is permanent, but for the source i like to set the
CD (current directory) to always refer from a (ref.txt) located in the desktop!
so that whenever i want to change the source path, i just need to edit it in
the ref.txt in the desktop without going back to the move.bat script to re-edit
it everytime...
so basically, is it possible to put a script in the move.bat that reads the source path from the desktop ref.txt & set it as CD (current directory)?
thanks
i have (move.bat) which Locate in c:\batch\records\move.bat
i would like to move all *.doc from c:\temp\doc\file1.doc file2.doc ...etc
to destination path for example, c:\permanent\destination\
so the destination path is permanent, but for the source i like to set the
CD (current directory) to always refer from a (ref.txt) located in the desktop!
so that whenever i want to change the source path, i just need to edit it in
the ref.txt in the desktop without going back to the move.bat script to re-edit
it everytime...
so basically, is it possible to put a script in the move.bat that reads the source path from the desktop ref.txt & set it as CD (current directory)?
thanks
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Re: set current directory (CD) in a bat from another ref.txt
That's what I did.
Re: set current directory (CD) in a bat from another ref.txt
Sorry but it seems not working!!
Any other scripts can use?
thanks
Any other scripts can use?
thanks
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Re: set current directory (CD) in a bat from another ref.txt
Oops. Mixed up tokens and delims:
Code: Select all
for /f "usebackq delims=" %%a in ("c:\path to ref\ref.txt") do cd /d "%%~a"
Re: set current directory (CD) in a bat from another ref.txt
this time is working perfectly!!
THANKS!!
THANKS!!