简体   繁体   English

计划的Powershell移至特定文件夹

[英]Scheduled Powershell Moves to Specific Folders

Thanks for viewing my question. 感谢您查看我的问题。 I was unable to find any information online in regards to my question. 我无法在线找到有关我的问题的任何信息。 I also have very basic experience in this area. 我在这方面也有非常基本的经验。

PowerShell Script: PowerShell脚本:

-Query folder for files (list?) -查询文件夹中的文件(列表?)

-Move file based on filename to folder with same name. -根据文件名将文件移动到同名文件夹中。 (Move with pipe to query?) (用管道移动以进行查询吗?)

-Move will also parse second part of file name to include subsequent matching folder name for destination folder. -Move还将分析文件名的第二部分,以包含目标文件夹的后续匹配文件夹名。

Files will contain many separate names so the move has to be on a loop. 文件将包含许多单独的名称,因此移动必须循环进行。

Ex. 防爆。 File - "Name 1" Scripts excutes moves file to folder with "name" then to subfolder "1". 文件-“名称1”脚本执行命令将文件移动到“名称”文件夹,然后移动到子文件夹“ 1”。

Just to be clear there will be multiple names and numbers so multiple destination paths. 为了清楚起见,将有多个名称和数字,因此有多个目标路径。 Basically every file will have a different destination but the destination will correlate to the file name. 基本上每个文件都有一个不同的目的地,但目的地将与文件名相关。 If there is a language more accessible for this function please let me know. 如果有更方便使用此功能的语言,请告诉我。

Something like the following will get you started 类似以下内容将帮助您入门

$files = Get-ChildItem -File

foreach($f in $files) {
  $dirname = $f -split " " -join "\"
  New-Item -ItemType Directory -Path ".\$dirname"
  Move-Item $f $dirname
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM