Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a text file with one line of text [may contain multiple words] that I need to 'read' back into my batch file as a variable. This variable is the directory where the user's IE Favorites will be copied to.
Here is what I have and it doesn't work.
set copydir=<"%USERPROFILE%\category.txt"
xcopy "%USERPROFILE%\Favorites" "%~dp0%copydir%\"
pauseThe user's profile path and copydir path may have names with spaces thus the need for the quotes [I think]
Help please!
Jesus is the Rock - ROCK ON!

What is this trying to do:
"%~dp0%copydir%\"
=====================================
If at first you don't succeed, you're about average.M2

If it's only one line:
set /p copydir=<"%USERPROFILE%\category.txt"If it's not then you could use the for /f command with skip, a counter, an if statement, ect.
The folowing for command will set the last line of the text file:
for /f "usebackq delims=" %%g in ("%USERPROFILE%\category.txt") do set copydir=%%gOn another note %~dp0 will give you the path of the batch file so I presume category.txt contains directory names only and they are below the location of the batch file. If this is so you should only have to specify:
"%copydir%\"And yes you will need quotes on file and directory names containing spaces for most tasks, cd/chdir is one that doesn't.

Works like a charm. Thanks.
It seems like I am always off just enough to make it not work. ;-)
Jesus is the Rock - ROCK ON!

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |