Using FOR or FORFILES batch command to individually archive specific files

前端 未结 1 671
[愿得一人]
[愿得一人] 2021-01-28 16:58

I have a set of .iso files in different directories and sub-directories:

 
    app1.iso
    app2.iso
    app3.iso
    
        a         


        
相关标签:
1条回答
  • 2021-01-28 17:30
    @ECHO OFF
    SETLOCAL
    SET "sourcedir=U:\sourcedir"
    FOR /f "delims=" %%a IN (
      'dir /s/b /a-d "%sourcedir%\*.iso" '
      ) DO (
      ECHO(7z a -t7z "%%~fa.7z" "%%~fa" -mx9 -mmt 
    )
    GOTO :EOF
    

    You would need to change the setting of sourcedir to suit your circumstances.

    The required 7z commands are merely ECHOed for testing purposes. After you've verified that the commands are correct, change ECHO(7z to 7z to actually archive the files.

    Note that the redirection-to-log is missing. This is done to allow the proposed actions to be displayed to the screen.

    0 讨论(0)
提交回复
热议问题