Jump to content

Copying old folders to a new location


churdaddy

Recommended Posts

I'm trying to write a page that would make a copy of a set of folders to a new location for an intranet. There is lots in the page for debugging that would vanish once I get it to work. The problem I'm getting is I cannot get XCOPY to work. Other dos commands work fine. 

<?php
$Client=$_GET['Client'];
$prefix="E:\\Files\\SYS\\JoshTestFolders\\";
$Year= $_GET['Year'];
$NewYear= $Year+1;
$file = "$prefix$Year\\$Client";
$newfile = "$prefix$NewYear\\$Client";
$newdir="$prefix$NewYear\\$Client";
$command1="C:\\WINDOWS\\system32\\cmd.exe /C \"dir\"";
$command="C:\\WINDOWS\\system32\\cmd.exe /C \"xcopy $file $newfile /E/I/q/y\"";

echo "$Client <BR />";
echo "$prefix <BR />";
echo "$Year <BR />";
echo "$NewYear <BR />";
echo "$file <BR />";
echo "$newfile <BR />";
echo "$command <BR />";
echo "$command1 <BR />";
$output = shell_exec("$command");
echo "<pre>$output</pre>";
$output = shell_exec("$command1");
echo "<pre>$output</pre>";

?>

 

This code exports a page that says

a1637

E:\Files\SYS\JoshTestFolders\

2007

2008

E:\Files\SYS\JoshTestFolders\2007\a1637

E:\Files\SYS\JoshTestFolders\2008\a1637

C:\WINDOWS\system32\cmd.exe /C "xcopy E:\Files\SYS\JoshTestFolders\2007\a1637 E:\Files\SYS\JoshTestFolders\2008\a1637 /E/I/q/y"

C:\WINDOWS\system32\cmd.exe /C "dir"

 

 

Volume in drive C has no label.

Volume Serial Number is F862-7821

 

Directory of C:\Sites\Bauerle\Search

 

03/30/2007  04:42 PM              .

03/30/2007  04:42 PM              ..

03/13/2007  06:31 PM               535 Search.php

04/03/2007  03:08 PM               698 testcopy.php

               2 File(s)          1,233 bytes

               2 Dir(s)     676,093,952 bytes free

 

Link to comment
https://forums.phpfreaks.com/topic/45464-copying-old-folders-to-a-new-location/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.