Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > Miscellaneous > Lounge

Notices

Reply
 
Thread Tools Search this Thread
Old 08-31-2019, 07:08 AM   #1
Tanjamuse
Wizard
Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!
 
Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
Help Zipping subfolders

Hello

I was hoping someone in here could help me with this problem:

I need to zip folders in a bunch of sub-folders.

Example:

Spoiler:

Root
Folder01
Subfolder 1
File1
File2
File3
Subfolder 2
File1
File2
Subfolder 3
File1
File2
File3
Folder02
Subfolder 1
File1
File2
File3
Subfolder 2
File1
File2


How it should be:

Spoiler:

Root
Folder01
SubFolder 1.zip
Subfolder 2.zip
Subfolder 3.zip
Folder02
SubFolder 1.zip
Subfolder 2.zip


I'm not that good with coding, but following a guide I managed to create this:

Code:
for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a "%%X.zip" "%%X\"
That zip's whatever's in the folder where it's placed, but I need it to go a level deeper like in the example above.

I know I can move it and run it separately in all the folders, but there are 3.000+ folders with 1.000.000+ subfolders distributed across.

I hope I make sense and someone can help me.

Thanks so much in advance.
Tanjamuse is offline   Reply With Quote
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,161
Karma: 1404241
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
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ereader with subfolders Simbeline Which one should I buy? 15 10-08-2020 08:24 AM
PRS-T2 Subfolders in collection carlosz123456 Sony Reader 0 08-13-2014 08:09 AM
RE: Zipping/Mimetype/? Hitch Sigil 31 08-02-2013 05:15 PM
Troubleshooting Cablibre and subfolders nimblem Amazon Kindle 6 02-13-2012 01:36 AM
Classic Subfolders? heaviside Barnes & Noble NOOK 5 09-25-2010 03:35 PM


All times are GMT -4. The time now is 03:09 PM.


MobileRead.com is a privately owned, operated and funded community.