这是我的情况.
这是我的文件夹结构
C:\DOCS\Project1\docname1\image.jpg \docname2\image.jpg \docname3\image.jpg C:\DOCS\Project2\docname1\image.jpg \docname2\image.jpg \docname3\image.jpg我正在尝试从.DOCS文件夹中运行一个.bat文件,并将所有image.jpgs上一个文件夹从"docname"文件夹移至" Project文件夹.
I'm trying to get a .bat going that will run from the "DOCS" folder, and move all the image.jpgs up one folder from the "docname" folders to the ""Project" folder.
文档名称和项目名称都不同,并且遵循特定的命名方案,因此我不能仅使用源目录和目标目录.
The docname and project names are all different and follow to specific naming scheme so I cant just use a source and dest directory.
必须是可以找到image.jpg并将其上移到父文件夹的东西.
It would have to be something that would just find the image.jpg and move it up a parent folder.
这是香港专业教育学院得到的,但没有用.
this is what ive got but it isnt working.
for /d %f in (docs\*) do ( pushd %f copy .\*.jpg .. popd )我每个项目文件夹只需要一个.jpgs.因此,更换/重新命名不是问题.
Also I only need one of the .jpgs per project folder. so replacing/renaming isnt an issue.
推荐答案@echo off setlocal enabledelayedexpansion for /f "tokens=*" %%a in ('dir /A:D /S /B "C:\docs\*"') do ( for %%y in ("%%a\*.jpg") do ( call :GETPARENTPARENT "%%y" ret echo ret=!ret! move /Y "%%y" "!ret!" ) ) goto:EOF :GETPARENTPARENT set fileP=%1 echo received=%fileP% for %%a in (%fileP%) do ( set parent=%%~dpa cd !parent!\.. set PPPath=!cd! for %%x in ("!PPPath!") do ( set "%~2=%%~dpnx" ) ) GOTO:EOF
更多推荐
将文件从子文件夹批量移动到父文件夹
发布评论