• Linux wizards UNITE??

    From paulie420@21:2/150 to All on Sunday, August 15, 2021 19:21:00
    Someone here always has the answers that blow me away... maybe this one will be easy for someone. :P

    I have a /directory with 2000 sub-directories... I want to run a script that goes in every sub-directory, zips the contents to a zip file with a name of that sub-directory, while adding a .ans file, then copying the .zip I created to the main /directory, and rm -r'ing the zipped sub-directory... :P

    Heres a few of the directory names, and the .ans file that I wanna include in the created .zip's... :P

    ----------
    Mechanicx a1k
    'Med Users' jp20topaz.ans
    Medellin panic
    Medicine spedes
    'Mega Expo' pi@SpeakerOffice:/export/Backup4TB/ROMs/rom/Amiga/Amiga_Demobase_3BBS/AmigaDem os $
    ----------
    In the end, I wanna end up with Machanicx.zip, a1k.zip, Med Users.zip, Medellin.zip, etc... with jp20topaz.ans in them, and the original directories removed. :P

    Cheers ya'll, sorry for the goofy question...



    |07p|15AULIE|1142|07o
    |08.........

    --- Mystic BBS v1.12 A47 2021/08/08 (Raspberry Pi/32)
    * Origin: 2o fOr beeRS bbs>>>20ForBeers.com:1337 (21:2/150)
  • From Bucko@21:4/131 to paulie420 on Monday, August 16, 2021 19:06:51
    On 15 Aug 2021, paulie420 said the following...

    Someone here always has the answers that blow me away... maybe this one will be easy for someone. :P

    I have a /directory with 2000 sub-directories... I want to run a script that goes in every sub-directory, zips the contents to a zip file with a name of that sub-directory, while adding a .ans file, then copying the .zip I created to the main /directory, and rm -r'ing the zipped sub-directory... :P

    Hey Paulie, I haven't done it in Linux yet, but in Windows I just created a
    bat file which I copied 12 sub directories (Partitions of an SD Card) to a folder on the HD then zipped everything in the folder and copied that file
    out of the directory to another directory and deleted the whole directory
    when done. I know this is not a big help but if you want to see my .bat file
    in windows I can paste it here and you can modify it to Linux..

    --- Mystic BBS v1.12 A46 2020/08/26 (Windows/32)
    * Origin: The Wrong Number Family Of BBS' - Wrong Number ][ (21:4/131)
  • From acn@21:3/127.1 to paulie420 on Tuesday, August 17, 2021 11:56:00
    Am 15.08.21 schrieb paulie420@21:2/150 in FSX_GEN:

    Hallo paulie420,

    I have a /directory with 2000 sub-directories... I want to run a script
    that goes in every sub-directory, zips the contents to a zip file with a name of that sub-directory, while adding a .ans file, then copying the .zip I created to the main /directory, and rm -r'ing the zipped sub-directory... :P

    Hmm, I have not tested the following lines, but something like that comes
    in my mind:

    for i in *; do
    if [ -d "$i" ]; then
    zip /"$i".zip "$i"/* jp20topaz.ans
    fi
    rm -R "$i"
    done

    I'm not sure about if the syntax of the "if" line is correct, but my idea
    -or the pseudo-code for the above- is:

    * For every file/dir in the current directory
    * check if it is a directory
    * zip all files in that dir + the .ans file to a file named after the
    directory, but in the root directory
    * remove directory

    If the directory has subdirectories, the zip command maybe has to get some more parameters, also if the zip file should be "flat".
    The "" around $i make sure that dirs with spaces in the names are treated correctly.

    I hope that helps a little :)

    Regards,
    Anna

    --- OpenXP 5.0.50
    * Origin: Imzadi Box Point (21:3/127.1)