删除" sample.ext.ext2"文件不具有" sample.ext"文件与它相关 [英] Removing a "sample.ext.ext2" file that has no "sample.ext" file associated with it
问题描述
在我的硬盘所有多媒体文件的应用程序创建 .mta code>文件(具有完全相同的名称)。我想要做的是检查的根文件夹的所有子文件夹,如果有
.mta code>与一些不相关的多媒体文件然后删除它。
详细的例子。比方说,我们有文件
01.mp3
01.MP3.mta
02.mkv
02.MKV.mta
03.jpg
03.JPG.mta
04.MP4.mta<< ==
正如你所看到的最后一个 .mta code>没有原始文件。我想删除最后一个文件。
我不知道这是否是可能的CMD。但是,以下功能不起作用。请看看
有关/ R %% i的(* .mta)也称:nomta %%我
暂停转到结束:nomta
集干=%1:.mta =%原来设置=%干%.mta
如果不存在%原装%做出口/ B
如果不存在干%%的人德尔/ A / Q 1%GOTO:EOF:结束做呼应
暂停
您可以使用for命令 DIR / A
喂养它都隐藏起来,不这样做隐藏文件名。这里有一个例子:
C:\\ TEMP \\ Z \\ Z> ATTRIB *
A C:\\ TEMP \\ Z \\ Z \\ foo.bar.mta
A H C:\\ TEMP \\ Z \\ Z \\ h2.mp4.mta
A C:\\ TEMP \\ Z \\ Z \\ hid.mp4
A H C:\\ TEMP \\ Z \\ Z \\ hid.mp4.mta
A C:\\ TEMP \\ Z \\ Z \\ zoo.bar
A C:\\ TEMP \\ Z \\ Z \\ zoo.bar.mtaC:\\ TEMP \\ Z \\ Z> FOR / F%F在('DIR / B / A * .mta')做,如果不存在%〜nF的回声%F>> žC:\\ TEMP \\ Z \\ Z> Z型
foo.bar.mta
h2.mp4.mta
因此具有取代德尔回声应达到你的目标。
The application creates .mta
files (with exactly same name) of all multimedia files in my HDD. What I want to do is to check all sub-folders of root folder if there is no multimedia file associated with some .mta
then delete it.
Detailed example. Lets say we have files
01.mp3
01.MP3.mta
02.mkv
02.MKV.mta
03.jpg
03.JPG.mta
04.MP4.mta <<==
As you see the last .mta
has no original file. I want to delete last file.
I don't know if it's possible with cmd. But following function doesn't work. Please take a look
For /r %%i in (*.mta) do call :nomta %%i
pause
goto end
:nomta
set stem=%1:.mta=%
set original=%stem%.mta
if not exist %original% do exit /B
if not exist %stem% do del /a /Q %1
goto :EOF
:end
echo done
PAUSE
You can use a for command to do this with dir /a
feeding it both hidden and non-hidden filenames. Here's an example:
C:\temp\z\z>attrib *
A C:\temp\z\z\foo.bar.mta
A H C:\temp\z\z\h2.mp4.mta
A C:\temp\z\z\hid.mp4
A H C:\temp\z\z\hid.mp4.mta
A C:\temp\z\z\zoo.bar
A C:\temp\z\z\zoo.bar.mta
C:\temp\z\z>for /f %F in ('dir /b/a *.mta') do if not exist "%~nF" echo %F >> z
C:\temp\z\z>type z
foo.bar.mta
h2.mp4.mta
so replacing the echo with a del should achieve your target.
这篇关于删除&QUOT; sample.ext.ext2&QUOT;文件不具有&QUOT; sample.ext&QUOT;文件与它相关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!