[Date Prev][Date Next] [Thread Prev][Thread Next]
[Date Index] [Thread Index] [New search]

Re: Shell script for removing FrameMaker debris files [LONG SUMRY, ATTACHES]



**** ATTACHMENT FREE VERSION -- GO TO FREE FRAMERS FOR ATTACHMENTS ****
Instructions for subscribing at end of message.

Framesters:

Here are all the replies to my plea for a shell script to remove FrameMaker
detritus at the end of a project (*.backup.fm, *.backup.book, *.auto.fm,
*.auto.book, *.recover.fm, *.recover.book, *.lck , *.mif, and *.mml).

WINDOWS


**** Mike Heine <mailto:<mheine@internorth.com>> contributed ...

A one-line batch file should do it. Here's the example for the 'backup'
files
Frame generates. Use wildcards as required for other flotsam and jetsam:

del x:\abcdir\*back*.* /s
[x: = target drive for delete operation
 abcdir =target directory for delete operation]
Note that target directory is the top-level directory containing *back*.*
files; the /s switch automatically extends the delete operation to ALL
directories below that top-level directory.

You could place an icon/shortcut  on the desktop that calls this *.bat or
*.cmd
file. I have tied it into a batch file that calls the backup program
controlling the DAT drive: First: delete *back*.* etc files, then: run
backup
program.


**** Hedley Finger <mailto:hedley_finger@myob.com.au> ...

... elaborated Mike Heine's suggestion and contributed a complete
self-documenting batch script for Windows.  [Ed: See attachment -- if it
didn't come through to Brad Framers, subscribe to Free Framers and get it
from there.  Instructions at end of post.]


**** Peter Gold <mailto:peter@highsoft.com> contributed ...

In Windows it's so EASY , using the Windows Find > Files command.

If your keyboard has a Windows "Logo" key, the combination Logo-f brings up

the Find command interface. To find multiple files or file types, enclose
them in quotes and separate them with commas, as in this example:
"*.backup.fm","*.book","*.auto.fm","*.lck" Choose the highest directory in
the tree you want to search, check Include Subfolders, and click Find Now.
When the files are found, click in the found list, select all files in the
list with Ctrl+A, and press Delete, or if you are really sure,
Shift+Delete.


**** Stuart Burnfield <mailto:stuartb@tpg.com.au> contributed ...

1) In Windows Explorer, do Tools > Find. On the Name and Location tab
   you can enter a list of patterns such as:

   *.backup.fm *.auto.fm *.backup.bk

   This will find all matching files under a directory. You can then
   do Ctrl-a and Del or Shift-Del to get rid of them.

2) Bruce Foster's Archive plug-in (Windows only) copies all the files
   used in a book (and only those files) to an archive or masters
   directory. It doesn't do anything to the original files, but if
   you just want to save the book along with all its chapters,
   imported graphics and text insets, you should be able to blitz the
   working directory and everything in it.  [Ed: See attachment -- if
   it didn't come through to Brad Framers, subscribe to Free Framers
   and get it from there.  Instructions at end of post.]


**** Peter Waszkewitz <mailto:pwaszkewitz@t-online.de> contributed ...

But there is a simpler way: download the original zip.exe (I
think it's from http://www.infozip.org) and use:

zip -rm obsolete * -i *.backup.fm *.backup.book ...

thend delete the obsolete.zip archive. For clarification: "-m" means
"move into archive", "-r" means: recurse directories. Then you can
even do a batch file with the above line followed by

del obsolete.zip

and there you are.


**** Simon Bate <mailto:sbate@extricity.com> contributed ...

The nice thing about Perl is that over time I've used forms of this script
on Macintosh, UNIX, and Windows.  [Ed: See UNIX section.]



MACINTOSH


**** Stuart Burnfield <mailto:stuartb@tpg.com.au> contributed ...

1) In Windows Explorer, do Tools > Find. On the Name and Location tab
   you can enter a list of patterns such as:

   *.backup.fm *.auto.fm *.backup.bk

No doubt Sherlock can do exactly the same sort of thing on Mac.

[Ed: On a Mac you could use Sherlock to find each file pattern one by one,
then select and drag all to the Trash.]


**** Simon Bate <mailto:sbate@extricity.com> contributed ...

The nice thing about Perl is that over time I've used forms of this script
on Macintosh, UNIX, and Windows.  [Ed: See UNIX section.]



UNIX


**** Thomas Michanek <mailto:thomas.michanek@telia.com> contributed ...

I can only offer a solution for UNIX:

find <starting dir> \( -name '*.backup.fm' -o -name '*.backup.book' \
-o -name '*.auto.fm' -o -name '*.auto.book' -o -name '*.recover.fm' \
-o -name '*.recover.book' -o -name '*.lck' \) -exec rm {} \;

This single command does not make any checks whether the corresponding
*.fm files exist or not, it just deletes all the specified files,
recursively from <starting dir>.


**** Stuart Burnfield <mailto:stuartb@tpg.com.au> contributed ...

On UNIX, do you need anything fancier than

    rm `ls -1R <file-list>`  [Ed: that's ell s - one R]

(Can't test this at the moment but something like it should do the
trick.)


**** Mike Hardy <mailto:Michael.Hardy@arm.com> contributed ...

For UNIX, it's something like:

find <dirs> -type f \( -name '<pattern_match>' -o -name
'<pattern_match>' -o -name '<pattern_match>' \) -print | xargs rm

where <dirs> is a list of directories to search, and each
<pattern_match> is a pattern to match for a file that you want to delete
(such as *.backup.fm).

For a generic cross-platform solution, I'd suggest that you write a perl
script.


**** Joe Woodard <mailto:joe@otelnet.com> contributed ...

Here's a ksh script you can adapt to remove what you want from a Unix
file hiearchy starting at the current working directory:

#!/bin/ksh
#
# Remove frame backup files from current directory and below
#

PROGRAM=$(basename $0)
REMOVE=false
ERROR=1
NO_ERROR=0

print "Listing Framemaker backup files in and below\n$PWD\n\n"
ANYTHING=/tmp/${PROGRAM}.$$
find . -type f \( -name '*.backup.*' -o -name '*.log' \) -print > $ANYTHING
if [ -s "${ANYTHING}" ]
then
    cat $ANYTHING
    while true
    do
        print "Remove backup files? (Y|N) \c"
        read answer
        answer=${answer:="N"}
        case $answer in
            Y|y|Yes|yes|YES)    REMOVE=true; break ;;
            N|n|No|no|NO)       REMOVE=false; break ;;
            *)                  continue ;;
        esac
    done
else # nothing to remove
    print "Nothing to remove \a"
    exit $NO_ERROR
fi

if [ $REMOVE = "false" ]
then
           print "Backup files NOT removed."
else
           find . -type f \( -name '*.backup.*' -o -name '*.log' \) -print
-exec rm -f "{}" \;
fi
exit $NO_ERROR


**** Simon Bate Simon Bate <mailto:sbate@extricity.com> contributed ...

If you've got Perl, you can use this script to clean up your current
directory.  Just put the script in the directory containing your FrameMaker
document and double click on the script file.  It creates a Backup folder
and moves all backup files into that folder.  You can then delete the
Backup
folder in one toss, rather than worrying that you've selected all the right
files.  [Ed: See attachment -- if it didn't come through to Brad Framers,
subscribe to Free Framers and get it from there.  Instructions at end of
post.]

One day I'll have enough time to hack with Windows to figure out how to
have
only one copy of the script (rather than per directory), but it works well
enough for me right now.


**** That's all, folks!

Regards,
Hedley

--
Subscribe to Free Framers -- send these commands in the body of a message
      subscribe framers your@email.address
      help
      end
to <mailto:majordomo@omsys.com?Subject=Subscribe%20Free%20Framers>.

Hedley Finger
Technical Communications/Technical communicator and FrameMaker mentor
MYOB Australia <http://www.myob.com.au/>
P.O. box 371   Blackburn VIC 3130   Australia
<mailto:hedley_finger@myob.com.au>
Tel. +61 3 9894 0945
Mob. +61 412 461 558



** To unsubscribe, send a message to majordomo@omsys.com **
** with "unsubscribe framers" (no quotes) in the body.   **