简体   繁体   English

使用Powershell复制文件而不重新创建子目录

[英]Copy files without recreating subdirectories using Powershell

The solution here works for me if the command is executed at a command prompt: 如果命令在命令提示符下执行,这里的解决方案适用于我:

Copy files without recreating subdirectories 复制文件而不重新创建子目录

However, I get an error if the command is in a batch file: 但是,如果命令在批处理文件中,则会出错:

"The following usage of the path operator in batch-parameter substitution is invalid %~nf" “批处理参数替换中路径运算符的以下用法无效%~nf”

How do you code this in Powershell? 你如何在Powershell中编写代码?

Replace any % with %% in a bat file. 在bat文件中用%%替换任何%

So %~nf becomes %%~nf 所以%~nf变成了%%~nf

Powershell equivalent: Powershell等效:

gci -r .\test | ?{-not $_.PsIsContainer} | copy-item -Destination .\test2

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 复制文件而无需重新创建子目录 - Copy files without recreating subdirectories 递归复制 powershell 中目录和子目录的内容 - Recursively copy contents of directory and subdirectories in powershell 如何使用CMD / Powershell查找目录(包括子目录)中的所有文件,然后显示具有某些扩展名的文件 - How to, using CMD/Powershell, find all files in a directory (including subdirectories), and then display files that have certain extensions 使用 CMD 或 Powershell 从以特定名称开头的文件夹中复制文件 - Copy Files from Folders That Start with a Particular Name Using CMD or Powershell 使用Powershell脚本从损坏的HD复制文件 - Copy files from corrupted HD using a powershell script 使用Powershell将文件从一台笔记本电脑复制到另一台笔记本电脑 - copy files from one laptop to another using powershell Powershell:将指定目录中的所有文件放入单独的、唯一命名的子目录中 - Powershell: Place all files in a specified directory into separate, uniquely named subdirectories 在子目录中搜索特定目录名称并复制文件(Windows批处理) - Search for specific directory names within subdirectories and copy files (Windows batch) 批处理文件以递归方式从多个子目录复制和重命名文件 - Batch file to copy and rename files from multiple subdirectories recursively 将文件从多个子目录复制到根目录并保留重复项 - Copy Files from multiple subdirectories to root directory and keep duplicates
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM