Link to home
Start Free TrialLog in
Avatar of samiam41
samiam41Flag for United States of America

asked on

copy files from Windows XP and Windows 7

Hi Experts.  I recently posted a question to get help creating a batch file to copy several different file types here.  That script works with Windows 7 clients but not the Windows XP (at least  not by default).

So, here is the situation.  I am copying files from our Windows XP clients, then running the in-place migration to Windows 7 and then copying the files back so I need the script to work with both operating systems or I need 2 scripts.

The requirements of the script are the same as the question I posted the link to above (copy files from several different formats from local pc to user network share).  Thanks for your help!
SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of samiam41

ASKER

Thanks for your help!  Is the robocopy executable the only file necessary to have in that share to make robocopy work?
yes it is a standalone executable.
robocopy does not like it when I use %userprofile% variable.

from the command prompt, i tried (where q is mapped to the dir containing robocopy.exe):
q:\robocopy "%userprofile%\my documents" s:\win7 *.doc

I get an error and see that the command is read as:
q:\robocopy c:\documents and setting\userA\my

I have tried several combinations of "" with the command with zero success.  Any ideas?
Avatar of oBdA
oBdA

Actually, it's not robocopy the expands environment variables; the shell is doing that before it starts the program.
Please paste the following three lines into your command prompt (you can paste them all at once):
>test.txt echo %UserProfile%
>>test.txt dir "%UserProfile%"
Q:\robocopy.exe "%UserProfile%\My Documents" "%Temp%" *.foo /xx /L>>test.txt 2>&1

Open in new window

This will not copy anything, it will just create a file test.txt. Please paste that here into a "code" "/code" box or attach it.
Just figured out the XP side:

robocopy "c:\documents and settings\%username%\my documents" s:\win7 *.doc

Working on the Win7 ver now
No no no. Don't do that. For all kinds of reasons, "c:\documents and settings\%username%" may not point to the actual user's profile. Always use "%UserProfile%" to access a user's profile.
Gotcha.  My bad.  Just trying to find the magic bullet to end my frustration with this.

I get "access is denied" errors on each line of code I copied and pasted from your previous example.  I will need to modify where the log file is created as the Q: drive is read only for this user.  Hold tight.
-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows     ::     Version XP010
-------------------------------------------------------------------------------

  Started : Wed Nov 14 09:29:44 2012

   Source : C:\Documents and Settings\jackson\My Documents\
     Dest : C:\DOCUME~1\jackson\LOCALS~1\Temp\

    Files : *.foo
	    
  Options : /L /COPY:DAT /XX /R:1000000 /W:30 

------------------------------------------------------------------------------

	                   0	C:\Documents and Settings\jackson\My Documents\

------------------------------------------------------------------------------

                Total    Copied   Skipped  Mismatch    FAILED    Extras
     Dirs :         1         0         1         0         0         0
    Files :         0         0         0         0         0         0
    Bytes :         0         0         0         0         0         0
    Times :   0:00:00   0:00:00                       0:00:00   0:00:00

    Ended : Wed Nov 14 09:29:45 2012

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:)  not that this will surprise you but you were dead-on.  Once I removed the flipping the \ on desktop and other lines, poof, it worked.

The headache I have didn't allow for me to think of using the temp dir.  Chalk it up to my noob class.

So now that I can use robocopy, how do I get the favorites folder to copy instead of each url without using the \  ??

Thanks oBdA
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here is the command I am using to copy the favorites folder which is causing me problems.

q:\robocopy "%userprofile%\favorites" S:\win7 /S /log+:S:\win7\CopiedFiles.txt /nc /njh /np /tee 

Open in new window


-the q: drive is the directory which contains the robocopy.exe
-s: drive is the network share for the user

The result of that command is taking the child folders and urls of the favorites folder on the local pc and putting them into the s:\win7 folder instead of placing them in the favorites folder on the s:\win7 directory.

What command or switch am I missing or have incorrect?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you oBdA!!  Thank you.
In case anyone is looking for additional points, I'm sure you will find this question to be easy for you to answer.  Thanks.

https://www.experts-exchange.com/questions/27937248/close-app-if-batch-script-detects-app-is-open-when-script-runs.html