mc: Re: Delete files that exist in the other panel



Hi!

re:http://mail.gnome.org/archives/mc/2008-May/msg00037.html

On Thursday 29 May 2008, Stefan Sorger rakstija:
I could swear that browsing the mc help I stumbled over a command
that deletes all files in the left panel directory that exist in the right
panel directory, comparing the files by size and/or timestamp.
If there is single mc command doing the same thing please somebody tell us! :)
Harijs


Midnight Commander 4.6.1 (Debian/Ubuntu 6.0.6.2 LTS) has it in the usermenu (F2): 
"d    Delete tagged files if a copy exists in the other directory"
Sometimes it doesn´t show up, depending on the file type, for example, when "@mc.menu" is highlighted.

Code in "/usr/share/mc/mc.menu":

-------------------
+ t r & ! t t
d       Delete file if a copy exists in the other directory.
        if [ "%d" = "%D" ]; then
          echo "The two directores must be different"
          exit 1
        fi
        if [ -f %D/%f ]; then        # if two of them, then
          if cmp -s %D/%f %f; then
            rm %f && echo %f: DELETED
          else
            echo "%f and %D/%f differ: NOT deleted"
            echo -n "Press RETURN "
            read key
          fi
        else
          echo %f: No copy in %D/%f: NOT deleted.
        fi

+ t t
D       Delete tagged files if a copy exists in the other directory.
        if [ "%d" = "%D" ]; then
          echo "The two directores must be different"
          exit 1
        fi 
        for i in %t
        do 
          if [ -f %D/$i ]; then
            SUM1="`sum $i`"
            SUM2="`sum %D/$i`"
            if [ "$SUM1" = "$SUM2" ]; then
              rm $i && echo ${i}: DELETED
            else
              echo $i and %D/$i differ: NOT deleted.
            fi
          else
            echo %f has no copy in %D/%f: NOT deleted.
          fi
        done
----------------

regards,


Vel
-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]