Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
How to compress multiple subfolders separately
Post Flair (click to view more posts with a particular flair)
Post Body

I have the directory "Main" with hundreds of parent folders, each one with subfolders, like this:

C:\Main
C:\Main\Parent1\Subfolder1\file1
C:\Main\Parent1\Subfolder1\file99
...
C:\Main\Parent1\Subfolder100\file1
C:\Main\Parent1\Subfolder100\file99

I would like to create zip files (I have 7zip) for each subfolder, like this:

C:\Main\Parent1\Subfolder1.zip
...
C:\Main\Parent1\Subfolder100.zip

I don't need the subfolders, just the files inside. Could you help?

Update: I found this code that helped. But now I have another problem: I have to move every subfolder.zip from its subfolder to its parent folder:

@echo off

:: Please drag and drop the main folder to this batch file

IF /i exist "%~1" (IF /i not exist "%~1\" exit) else (exit)
pushd "%~1"

for /f "Delims=" %%a in ('dir /b /s /ad') do (
                                              cd /d "%%a"
                                              7z.exe a -sdel "%%~na.zip" *.*
                                             )
popd

Update2: Found another script to move the files from Subfolder to Parent:

@echo off
setlocal enabledelayedexpansion

for /f "tokens=*" %%a in ('dir /A:D /S /B "C:\Main\*"') do (
    for %%y in ("%%a\*.zip") do (
        call :GETPARENTPARENT "%%y" ret

        echo ret=!ret!
        move /Y "%%y" "!ret!"
    )
)

goto:EOF

:GETPARENTPARENT
set fileP=%1
echo received=%fileP%
for %%a in (%fileP%) do (
    set parent=%%~dpa
    cd !parent!\..
    set PPPath=!cd!
    for %%x in ("!PPPath!") do (
        set "%~2=%%~dpnx"
    )
)
GOTO:EOF

Author
Account Strength
90%
Account Age
6 years
Verified Email
Yes
Verified Flair
No
Total Karma
1,016
Link Karma
105
Comment Karma
806
Profile updated: 4 days ago
Posts updated: 3 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago