I've been given the task of creating a batch file to copy a users "favorites", thats all fine and dandy...(I can copy fine.) my problem is I had can't figure out how to do this with out having it be a specific users name.
Instead of the batch saying something like this.
"Copy C:\Documents and Settings\laird\favorites\ O:\backup"
I need it to automatically do this without having to write each and every indivdual user name for each batch file.
So should it be something like?
"Copy C:\Documents and Settings\"username"\favorites\ O:\backup"
Or
"Copy C:\Documents and Settings\"*.*"\favorites\ O:\backup"?
Help and the answer would be greatly apperciated....
Batch file help needed
Moderator: Thanas
Batch file help needed
"LairdCorp, where total dominion is our number one goal!"-LairdCorp's Motto
- Mad
- Jedi Council Member
- Posts: 1923
- Joined: 2002-07-04 01:32am
- Location: North Carolina, USA
- Contact:
Simple method:
When you run the batch file, give it the parameter of ther username. So "testbatch laird" would replace %1 with "laird" while "testbatch Administrator" would replace %1 with "Administrator".
To get more complicated, you can try playing around with the FOR command.
Code: Select all
copy "C:\Documents and Settings\%1\favorites\" O:\backup
To get more complicated, you can try playing around with the FOR command.
Later...
Make a batch file with something like this:
Run that batch program from within the Documents and Settings folder. Test this on a machine that isn't critical first It won't copy an empty Favorites folder, unfortunately.
Code: Select all
@ECHO OFF
FOR /R /D %%G IN (*FAVORITES) DO XCOPY /E /Q "%%G" "O:\BACKUP%%~pGFavorites\"