使用批处理文件自动化 windows

Automate windows with batch file

我一直在努力做到这一点,但一直做不到。我有一个包含很多文件的文件夹,我想遍历所有文件,读取它们的名称,如果名称中的任何地方有类似“_NOT”的字符串,我会将该文件复制到另一个文件夹,在最后我会压缩该文件夹,然后删除该文件夹并将 zip 文件移动到另一个位置。如果该位置的 zip 文件已经存在,我会重写它。

简单吧?我会通过 Excel 中的 VBA 宏轻松地做到这一点,但我不知道如何每天从 windows 中做到这一点。

我只是找不到好的教程。

对于包含此内容的优秀教程的任何帮助或指导,我们将不胜感激。

干杯!

@echo off
CLS

REM Before you use this, make sure to set the paths. 
REM Make sure you download the 7z command line utility, and plug the path in.


set pathtoFolder=""
set destination=""
set sevenZipdir=""

FOR /R %pathtoFolder% %%G IN (*_NOT) DO (
  echo %%G
  xcopy "%%G" %destination% 
)

%sevenZipdir% a -tzip _not.zip %destination%
RMDIR /Q /S %pathtoFolder%