• ZIP file check

    From Mindless Automaton@VERT/ELDRITCH to DOVE-Net.Unix_Discussion on Thursday, December 16, 2010 16:34:13
    I am looking for an easy way to check through my filebase and move any
    bad zip files to a specific directory. When I moved over from Win32 to
    linux (as the harddrive failed) it seems a number of files really didn't
    make it.

    I imagine there is a way to script it, but I haven't a clue how. Any
    snippets online to do this?

    Thanks!

    Mindless Automaton
    ---
    þ Synchronet þ Eldritch Clockwork BBS - eldritch.darktech.org
  • From Amcleod@VERT to Mindless Automaton on Thursday, December 16, 2010 20:11:28
    Re: ZIP file check
    By: Mindless Automaton to DOVE-Net.Unix_Discussion on Thu Dec 16 2010 04:34 pm

    I am looking for an easy way to check through my filebase and move any
    bad zip files to a specific directory. When I moved over from Win32 to linux (as the harddrive failed) it seems a number of files really didn't make it.

    I imagine there is a way to script it, but I haven't a clue how. Any snippets online to do this?

    Use /usr/bin/find to locate all the zip files,
    /usr/bin/unzip to test them and /usr/bin/mv to move them into whatever destination you choose.:

    for F in `find . -name "*.zip"`; do
    unzip -t "$F" >/dev/null 2>&1 || mv "$F" /destination/directory;
    done

    You can type this as three separate lines at the shell prompt. The shell will wait for the third line ("done") before executing the whole lot. Just get your punctuation right! Yes, those are back-ticks around the find command! :-)

    Note this searches in "." (current directory) and subdirectories, so if you want to search elsewhere change the find command to suit. Use "/" (no quotes) to search the entire disk.

    Also, this searches for .zip files and not .ZIP files or .Zip files. Do multiple passes or change the find command to suit:

    -name "*.zip" -o -name "*.ZIP" -o -name "*.Zip"

    Good luck!

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ telnet://vert.synchro.net
  • From Mindless Automaton@VERT/ELDRITCH to Amcleod on Tuesday, December 21, 2010 10:37:28
    Amcleod wrote:


    Good luck!

    ---
    � Synchronet � Vertrauen � Home of Synchronet � telnet://vert.synchro.net

    Thanks! I knew someone with the Kung-fu would be lurking. :)

    -Mindless Automaton
    ---
    þ Synchronet þ Eldritch Clockwork BBS - eldritch.darktech.org