View Single Post
Old 09-01-2019, 10:37 AM   #2
Divingduck
Wizard
Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.
 
Posts: 1,166
Karma: 1410083
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
Here is a possible solution.

With the given structure you need to delete all created zip files before you run it once more. Otherwise you will zip the before created zip files to additional archives. So, be careful if you like to do this with a huge amount of directories. Or better build a parallel structure to move all zip files to as this is better manageable.

Spoiler:
Code:
echo off
cls

Set _SourcePath="c:\Users\Armin\Documents\Calibre\Tanja\Calibre"
Set _7z="c:\Program Files\7-Zip\7z.exe"
Set _tmp="c:\temp"

For /R %_SourcePath% %%X in (.) do (

   REM Some checks for %%X (remove REM in lines below if needet)
   REM  echo X:           %%X
   REM  echo dX_LW:       %%~dX
   REM  echo pX:          %%~pX
   REM  echo dpX_Path:    %%~dpX
   REM  echo nX_Filename: %%~nX
   REM
   
   REM
   REM Check if directory include files
   REM Sample:
   REM if exist "%%~dpnX" dir /b /A:-d "%%~dpnX">nul 2>nul && @echo "%%~dpnX" is not empty
   REM
   
   if exist "%%~dpnX" dir /b /A:-d "%%~dpnX">nul 2>nul && @(
      
      REM 
      
      echo %_7z% a -tzip "%%~nX.zip" "%%~dpnX\" 
      REM Zip files from 
      %_7z% a -tzip "%%~nX.zip" "%%~dpnX\" -w%_tmp%
      
      REM Move zip file to coresponding direktory
      move "%%~nX.zip" "%%~dpX"
      )
   )
   
Set _SourcePath=""
Set _7z=""
Set _tmp=""
 
echo on


Best regards, DD

Last edited by Divingduck; 09-05-2019 at 12:14 PM. Reason: correct a stupid mistake move [a -tzip] back to the correct place
Divingduck is offline   Reply With Quote