如何将文件从具有固定名称的子文件夹移动到文件夹树中具有不同名称的父文件夹?

How to move files from a subfolder with fixed name to its parent folder with varying name in a folder tree?

我有很多图片在不同的文件夹中,但每个文件夹也在一个文件夹中。看起来像这样

<path>\(nameoffolder)\full\

我想将名为 full 的文件夹中的所有图像移动到其父文件夹 (nameoffolder)

(nameoffolder) 不是一个连续的数字或任何东西,但它的名字变化很大。

有没有办法批量执行此操作,最好使用命令行?

C:\Temp 替换为根目录路径后,将此批处理文件用于此简单任务:

@echo off

rem For each subdirectory in the specified directory check if there is
rem a subdirectory with name "full" containing 1 or more files. If this
rem condition is true, move the files from subdirectory "full" to its
rem parent directory and then delete the subdirectory "full".

for /D %%F in ("C:\Temp\*") do (
    if exist "%%F\full\*" (
        echo Moving files to %%F ...
        move /Y "%%F\full\*" "%%F" >nul
        rd "%%F\full"
    )
)

要了解使用的命令及其工作原理,请打开命令提示符 window,在其中执行以下命令,并仔细阅读为每个命令显示的所有帮助页面。

  • echo /?
  • for /?
  • if /?
  • move /?
  • rem /?
  • rd /?