如何将单个文件复制到目录中的所有子文件夹? [英] How Do I Copy A Single File To All Subfolders In A Directory?
问题描述
复制
C:\ TempC\ABSS \d2kwut60.dll
进入任何子文件夹
C:\Program Files\Java \ all子文件夹
如何在PowerShell中执行此操作?
代码如下所示:
#PowerShell的New-Item创建一个文件夹
$ Location =C:\ TempC \
New-Item -Path $ Location -NameABSS-ItemTypedirectory
#Invoke-Item $ Location
$ targetdirectory =C:\ TempC \ ABSS
$ sourcedirectory =\\\\\ Software \ABSS \ ABSS Files \
#错误处理
#Copying项目从源到新创建的目标目录在共享位置的本地机器上
if(!(Test-Path -path $ targetdirectory)){New-Item $ targetdirectory -Type Directory}
Copy-Item - 路径$ sourcedirectory \d2kwut60.dll -Destination $ t argetdirectory
Copy-Item -Path $ sourcedirectory \ _jacob.dll -Destination $ targetdirectory
Copy-Item -Path $ sourcedirectory\JNIsharedStubs.dll -Destination $ targetdirectory
复制项目-Path $ sourcedirectory \webutil.properties -Destination $ targetdirectory
复制项目$ targetdirectory \d2kwut60.dll C :\ Program Files \ Java
Location =C:\ TempC \
New-Item -Path
Location -NameABSS-ItemTypedirectory
#Invoke-Item
< blockquote>位置
copy
C:\TempC\ABSS\d2kwut60.dll
into any subfolders in
C:\Program Files\Java\all sub folders
How can I perform this in PowerShell?
Code is shown below:
# PowerShell's New-Item creates a folder
$Location = "C:\TempC\"
New-Item -Path $Location -Name "ABSS" -ItemType "directory"
#Invoke-Item $Location
$targetdirectory = "C:\TempC\ABSS"
$sourcedirectory = "\\server2\Software\ABSS\ABSS Files\"
#Error handling
#Copying Items over from source to new created target directory on local machine from the share location
if (!(Test-Path -path $targetdirectory)) {New-Item $targetdirectory -Type Directory}
Copy-Item -Path $sourcedirectory\d2kwut60.dll -Destination $targetdirectory
Copy-Item -Path $sourcedirectory\jacob.dll -Destination $targetdirectory
Copy-Item -Path $sourcedirectory\JNIsharedStubs.dll -Destination $targetdirectory
Copy-Item -Path $sourcedirectory\webutil.properties -Destination $targetdirectory
Copy-Item $targetdirectory\d2kwut60.dll C:\Program Files\Java
Location = "C:\TempC\"
New-Item -Path
Location -Name "ABSS" -ItemType "directory"
#Invoke-Item
Location
这篇关于如何将单个文件复制到目录中的所有子文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!