我最近一直在玩Batch编程,让我解释整个想法,然后我会写下我被困的地方。
我在 C:\ Test
中通过FTP接收了一大堆Zip文件我想解压缩包含其他Zipped文件的内容。 此时,我只想根据名称包含LSP或LSG或LSP021或LSG021来详细说明这些文件的一个子集
[*LSP*.*,*LSG*.*,*LSP021*.*,*LSP021*.*]
当我找到匹配的文件时,我必须
我在哪里:
rem loop through all the zips
for /R "C:\Test\" %%c in (*.zip) do (`enter code here`
rem make a temporary folder with the same name as zip to house the zip content
if not exist %%~nc md %%~nc
rem extract zip content into the temporary folder
7za e -o"%%~nc" %%c
if exist "%%~nc" (
rem jump into the temporary folder
pushd "%%~nc"
if exist *.* (
rem loop through all the files found in the temporary folder and prefix it with the zip's name
for %%i in (*.*) do (
ren "%%i" "%%~nc.%%i"
)
)
rem jump out of the temporary folder
popd
)