我尝试编写脚本来浏览大型目录并递归复制文件,但目标只能一次接受2 gig的信息。有没有办法将转移分解成小于2个演出的部分? 我可以编写一个简单的脚本复制主目录,但问题是目标不能同时接受这些大型传输。我想某种方式有一个主要功能来创建子功能,以便在较小的段或会话中传输数据,但我不太清楚如何做到这一点。像这样的东西,但分成几段。
$SPOnlineDir = "Our sharepoint online library address"
$MainStore = @("\\server\Dir1", "\\server\Dir2", "\\server\Dir3")
function Copy-ToSPO()
{
Foreach($StoreInst in $MainStore)
{
Copy-Item -LiteralPath $StoreInst -Destination $SPOnlineDir -Force
}
}
Copy-ToSPO
答案 0 :(得分:0)
找到一个带有一点C#的解决方案:
命名空间ConsoleApplication2 { 课程 { static void Main(string [] args) { var Source = GetSourceDirectory(); var Destination = GetDestinationDirectory();
CopyDirectory(Source, Destination);
Console.WriteLine("\n\nFinished.");
Console.ReadKey(true);
}
static DirectoryInfo GetSourceDirectory()
{
var verifyPath = false;
var pathExists = false;
var path = "";
while(!verifyPath)
{
while(!pathExists)
{
Console.WriteLine("Please enter the Source Directory path.");
path = Console.ReadLine();
Console.WriteLine("Verifying directory exists...");
pathExists = Directory.Exists(path);
if (!pathExists)
Console.WriteLine("That path does not exist.");
}
Console.WriteLine("Directory found.");
Console.WriteLine("Please verify the source file path (Y or N):");
Console.WriteLine(path);
verifyPath = GetVerification();
}
return new DirectoryInfo(path);
}
static DirectoryInfo GetDestinationDirectory()
{
var verifyPath = false;
var path = "";
while (!verifyPath)
{
var pathExists = false;
var createDir = false;
while (!pathExists)
{
Console.WriteLine("Please enter the Destination Directory path.");
path = Console.ReadLine();
Console.WriteLine("Verifying directory exists...");
pathExists = Directory.Exists(path);
if (!pathExists)
{
Console.WriteLine("Directory does not exist. Would you like to create it?");
createDir = GetVerification();
pathExists = createDir;
}
else
Console.WriteLine("Directory found.");
}
Console.WriteLine("Please verify the source file path (Y or N):");
Console.WriteLine(path);
verifyPath = GetVerification();
if (verifyPath && createDir)
Directory.CreateDirectory(path);
}
return new DirectoryInfo(path);
}
static bool GetVerification()
{
char[] VerificationChoices = { 'y', 'Y', 'n', 'N' };
var VerifiedChar = Console.ReadKey().KeyChar;
while (!VerificationChoices.Contains(VerifiedChar))
VerifiedChar = Console.ReadKey().KeyChar;
Console.Write("\n\n");
return VerifiedChar == 'Y' || VerifiedChar == 'y';
}
static void CopyDirectory(DirectoryInfo DirectoryToCopy, DirectoryInfo Destination)
{
foreach(var SubFolder in DirectoryToCopy.GetDirectories())
{
var SubDestination = Destination.CreateSubdirectory(SubFolder.Name);
Console.WriteLine("Creating Directory: " + SubDestination.FullName);
CopyDirectory(SubFolder, SubDestination);
}
foreach(var File in DirectoryToCopy.GetFiles())
{
var FullDestinationPath = Destination.FullName + "\\" + File.Name + File.Extension;
File.CopyTo(FullDestinationPath);
Console.WriteLine("Creating File: " + FullDestinationPath);
}
}
}
}
感谢您的投入。