[comp.sources.amiga] arc_rename

ain@j.cc.purdue.edu (Patrick White) (07/28/88)

Submitted by:	barrett@crabcake.cs.JHU.EDU (Dan Barrett)
Summary:	renames files to less than 12 char and creates execute script to convert it back.
Poster Boy:	Patrick White	(ain@j.cc.purdue.edu)
Archive Name:	sources/amiga/volume5/arc_rename.d.sh.Z binaries/amiga/volume8/arc_rename.d.sh.Z
tested but not compiled.
 
NOTES:
   Had to burst the arc to get the files out.
 
 
-- Pat White   (co-moderator comp.sources/binaries.amiga)
ARPA/UUCP: j.cc.purdue.edu!ain  BITNET: PATWHITE@PURCCVM  PHONE: (317) 743-8421
U.S.  Mail:  320 Brown St. apt. 406,    West Lafayette, IN 47906
[archives at: j.cc.purdue.edu.ARPA]
 
========================================
 
#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:	Shell Archiver
#	Run the following text with /bin/sh to create:
#	README
#	ARCre.doc
# This archive created: Fri Jul 22 18:41:27 1988
# By:	Patrick White (PUCC Land, USA)
cat << \SHAR_EOF > README
	Here is ARCre.  This is a utility that renames Amigados files to
MSDOS compatible names for use with ARC and creates a file  called 
EXECUTE.ME to rename them back.  This uuencoded file is in ARC format.
Not written by me, but in the public domain.  It comes with source too...

----------------------------------------------------------------------------
	"Isn't fun the best thing to have?"

			lachac@topaz.rutgers.edu
SHAR_EOF
cat << \SHAR_EOF > ARCre.doc

ARCre - Create rename scripts so that files with long names can be
        easily put into ARChives.

Here's how to use it:

  ARCre [file(s) to be ARCed...]         : Create the rename scripts.
  execute ARCre.bat                      : Rename the files to be ARCed.
  ARC a ARChive ARCfile.* execute.me     : Create the ARChive.
  execute execute.me                     : Rename the files back.

  ARCre takes file names like the ARC program does.  (It will accept
  the '*' wildcard.)  Two scripts are produced: "ARCre.bat" and
  "execute.me".  The first one will rename the files to "ARCfile.#",
  where '#' is 1,2,3,...  The second one will rename the files back
  to their original names.

Copyright (c) 1987 John R. Hoffman

This program is placed in the public domain as long as the above
copyright is included.  Sale of this program except for REASONABLE 
media costs is prohibited.

The credit for the idea for this program goes to John Foust.

To create with MANX: cc ARCre.c
                     ln ARCre.o -lc

                                     John Hoffman (Plink: JRH)
SHAR_EOF
#	End of shell archive
exit 0

ain@j.cc.purdue.edu (Patrick White) (07/28/88)

Submitted by:	barrett@crabcake.cs.JHU.EDU (Dan Barrett)
Summary:	renames files to less than 12 char and creates execute script to convert it back.
Poster Boy:	Patrick White	(ain@j.cc.purdue.edu)
Archive Name:	sources/amiga/volume5/arc_rename.s.sh.Z
tested but not compiled.
 
NOTES:
   Had to burst the arc to get the files out.
 
 
-- Pat White   (co-moderator comp.sources/binaries.amiga)
ARPA/UUCP: j.cc.purdue.edu!ain  BITNET: PATWHITE@PURCCVM  PHONE: (317) 743-8421
U.S.  Mail:  320 Brown St. apt. 406,    West Lafayette, IN 47906
[archives at: j.cc.purdue.edu.ARPA]
 
========================================
 
#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:	Shell Archiver
#	Run the following text with /bin/sh to create:
#	README
#	ARCre.c
# This archive created: Fri Jul 22 18:40:59 1988
# By:	Patrick White (PUCC Land, USA)
cat << \SHAR_EOF > README
	Here is ARCre.  This is a utility that renames Amigados files to
MSDOS compatible names for use with ARC and creates a file  called 
EXECUTE.ME to rename them back.  This uuencoded file is in ARC format.
Not written by me, but in the public domain.  It comes with source too...

----------------------------------------------------------------------------
	"Isn't fun the best thing to have?"

			lachac@topaz.rutgers.edu
SHAR_EOF
cat << \SHAR_EOF > ARCre.c
/*
 * ARCre - Create rename scripts so that files with long names can be
 *         easily put into ARChives.
 *
 * Here's how to use it:
 *
 *   ARCre [file(s) to be ARCed...]         : Create the rename scripts.
 *   execute ARCre.bat                      : Rename the files to be ARCed.
 *   ARC a ARChive ARCfile.* execute.me     : Create the ARChive.
 *   execute execute.me                     : Rename the files back.
 *
 *   ARCre takes file names like the ARC program does.  (It will accept
 *   the '*' wildcard.)  Two scripts are produced: "ARCre.bat" and
 *   "execute.me".  The first one will rename the files to "ARCfile.#",
 *   where '#' is 1,2,3,...  The second one will rename the files back
 *   to their original names.
 *
 * Copyright (c) 1987 John R. Hoffman
 *
 * This program is placed in the public domain as long as the above
 * copyright is included.  Sale of this program except for REASONABLE 
 * media costs is prohibited.
 *
 * The credit for the idea for this program goes to John Foust.
 *
 * To create with MANX: cc ARCre.c
 *                      ln ARCre.o -lc
 *
 */

static char *Copyright = "Copyright (c) 1987 John R. Hoffman";

#include <stdio.h>

#define RENAME1  "ARCre.bat"
#define RENAME2  "EXECUTE.ME"
#define BASENAME "ARCfile.%d"

FILE *fopen();
char *scdir();

main(argc, argv)
int argc;
char *argv[];
{
    int i, fcnt;
    char *cp, name[50];
    FILE *fp1, *fp2;

    fp1  = NULL;
    fp2  = NULL;
    fcnt = 1;

    if ( argc <= 1 ) {
        fprintf(stderr, "Usage: ARCre files ...\n");
        exit();
    }

    for ( i = 1; i < argc; i++ ) {

        while ( (cp = scdir(argv[i])) != (char *) NULL ) {

            if ( fp1 == (FILE *) NULL ) {
                if ( (fp1 = fopen(RENAME1, "w")) == (FILE *) NULL ) {
                    fprintf(stderr, "ARCre: Error opening \"%s\".\n", RENAME1);
                    exit();
                }
            }

            if ( fp2 == (FILE *) NULL ) {
                if ( (fp2 = fopen(RENAME2, "w")) == (FILE *) NULL ) {
                    fprintf(stderr, "ARCre: Error opening \"%s\".\n", RENAME2);
                    if ( fp1 != (FILE *) NULL ) {
                        fclose(fp1);
                    }
                    exit();
                }
            }

            sprintf(name, BASENAME, fcnt++);

            fprintf(fp1, "rename \"%s\" %s\n", cp, name);

            fprintf(fp2, "rename %s \"%s\"\n", name, cp);

        }

    }

    if ( fcnt == 1 ) {
        fprintf(stderr, "ARCre: No matching files found.\n");
    	exit();
    }

    if ( fp1 != (FILE *) NULL ) {
        fclose(fp1);
    }

    if ( fp2 != (FILE *) NULL ) {
        fclose(fp2);
    }

    exit();
}
SHAR_EOF
#	End of shell archive
exit 0