Find and EXEC

This is a huge issue. and I need it fixed ASAP.

account-system      gate-system           race_traffic_sensor
achievement-system  global                race_voicepack
admin               glue-system           realdriveby
admin-system        gps                   realism-system
animation-system    gps-system            realistictrains
anticheat-system    hay                   realtime-system
apps-system         heligrab              reload
assault             help                  report-system
as-sharks           helpmanager           roadblock-system
as-supermarket      help-system           runcode
bank-system         interiors             saveplayer-system
briefcase           interior-system       scoreboard
briefcaserace       item-system           shop-system
camera-system       job-system            sittablechairs
carlist-system      joinquit              social-system
carshop-system      killmessages          spike-system
cdm                 language-system       stealth
character-system    license-system        sth-coookiepirates
chat-system         lses-system           superman
computers-system    lspd-system           tag-system
ctf                 map-system            tdm
ctv                 mdc-system            tdma
dancer-system       missiontimer          teammanager
deathmatch          mods-system           tooltip
driveby             move_cursor           tooltips-system
edf                 move_freecam          tow-system
editor_gui          move_keyboard         valhallashield
editor_main         msgbox                vehicle-mods-system
elevator-system     mtaworkaround         vehicle-plate-system
event-system        object-system         vehicle-system
faction-system      parachute             vgaccount
fallout             performancebrowser    vG-logs
fiddycal            phone-system          vgscoreboard
flood               pickuphandler         video-poker
freecam             race                  voice
freecam-tv          race_delay_indicator  votemanager
freeroam            race_nos              weaponcap
fuel-system         race_racewar          weather-system
gatekeepers-system  race_toptimes

That is a list of all of my folders. I need zip files created of all of those files. I can get everything I need when I do find -maxdepth 1
It will show all of those directories. Now. I need to zip the contents of those directories. to zip files. named after the folder they came out of. So. all the files in weather-system, would come out as a zip file. which has the contents of weather-system in the weather-system.zip. without the folder called weather system inside. so. instead of

weather-system.zip
-weather-system(D)
-Files and such

I need
weather-system.zip
-Files and such

If you have any idea how to do it. I would be in a much better shape.

I have been trying something like
find -maxdepth 1 -exec zip {} {}/* \;
but. that looks ridiculous. and doesn't work

First off, you need to specify one or more path arguments to man find (linux), as in:

find * -maxdepth 1 -exec zip {} {}/* \;

However, find does not interpolate pattern matching characters, so "*" is not expanded as you expect. You need to invoke the zip in a shell, as follows:

find * -maxdepth 1 -exec sh -c 'zip {} {}/*' \;

Alternately, you could have:

for dir in *; do
    zip ${dir} ${dir}/*
done

You clever bastard! This is pure win!

M'whahahah :slight_smile:

I spoke too soon. It worked once. then it stopped working. Not sure what happened. Its not getting the whole * thing. It still grabs the parent directory. Not sure why. I think its considered the relative path.

What you can do is:

find * -maxdepth 1 -exec echo sh -c 'zip {} {}/*' \;

and

find * -maxdepth 1 -exec sh -c 'echo zip {} {}/*' \;

to determine what is being invoked.