【问题标题】:Moving files to directory above Powershell [duplicate]将文件移动到Powershell上方的目录[重复]
【发布时间】:2019-01-09 14:27:05
【问题描述】:

我有以下路径:

C:\Customer\M\Morri\ft.txt
C:\Customer\M\Morri\dropbox\fed.xslx
C:\Customer\T\Tori\ss.txt
C:\Customer\T\Tori\dropbox\sed.xslx

我想将它上移一个级别以匹配以下内容:

C:\Customer\Morri\ft.txt
C:\Customer\Morri\dropbox\fed.xslx
C:\Customer\Tori\ss.txt
C:\Customer\Tori\dropbox\sed.xslx

我该怎么做?

所以整个结构应该保持不变减去 M & T 级文件夹(同样,这实际上可以命名任何东西)。

【问题讨论】:

标签: powershell


【解决方案1】:

到目前为止,我已经尝试了以下方法:

Get-ChildItem .\*\*
$dir = 'C:\Customer'
Set-Location $dir
Get-ChildItem .\*\* |
Move-Item -Destination .\ -Verbose

这确实符合我的要求,但现在我想删除空文件夹 M 和 T(我刚刚从中移动文件和子文件夹的文件夹)。

我如何让它识别出我只想删除这些?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-06
    • 2021-11-16
    • 1970-01-01
    • 2020-10-07
    • 1970-01-01
    • 2013-06-10
    • 2013-04-09
    • 1970-01-01
    相关资源
    最近更新 更多