I am relatively new to making batch files and while I found some examples of deleting files under a certain file size, I can't find one that simply moves them into a folder (at least not with a solution). This is what I have:
我对制作批处理文件相对较新,虽然我发现了一些删除特定文件大小的文件的例子,但我找不到一个只是将它们移动到文件夹中的文件(至少没有解决方案)。这就是我所拥有的:
@echo off
setlocal
::Make fail Folder
md Fail
::Delete Files lower than minimum size
:: Size is in bytes
set "min.size=10000"
for /f "usebackq delims=;" %%A in (`dir /b /A:-D *.*`) do If %%~zA LSS %min.size% del "%%A"
As you can see it makes a folder named "Fail" in the folder it is in, and this code deletes the files with a size under 10KB.
正如您所看到的,它在其所在的文件夹中创建了一个名为“Fail”的文件夹,此代码将删除大小小于10KB的文件。
This script works quite well. The problem is, I do not want to delete the files, but move them to the newly created folder. Can somebody provide assistance?
这个脚本运行得很好。问题是,我不想删除文件,而是将它们移动到新创建的文件夹中。有人可以提供帮助吗?
1 个解决方案
#1
1
Replace del "%%A"
with move "%%A" .\fail\
用移动“%% A”替换del“%% A”。\ fail \
(assuming the fail
directory is a subdirectory of the current directory as your code suggests)
(假设失败目录是当前目录的子目录,如代码所示)
#1
1
Replace del "%%A"
with move "%%A" .\fail\
用移动“%% A”替换del“%% A”。\ fail \
(assuming the fail
directory is a subdirectory of the current directory as your code suggests)
(假设失败目录是当前目录的子目录,如代码所示)