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

A utility for renaming old-style file names

This page is part of the web mail archives of SRFI 104 from before July 7th, 2015. The new archives for SRFI 104 contain all messages, not just those from before July 7th, 2015.

The new revision of SRFI 103 changes the file name extension for R6RS
library files from .sls and .IMPL.sls to .r6rs-lib and .IMPL-r6rs-lib.
I've made a program to assist with renaming files, and it is available
as the rename-old-style.r6rs-prog file in the tar-ball at:
http://srfi.schemers.org/srfi-104/library-files-utilities.tar.gz .

I've successfully used it to rename the files of my collections of
R6RS libraries, and have tested it with Ikarus and PLT.

It's an R6RS program and it requires the library
(srfi :104 library-files-utilities), available in the same tar-ball,
and a number of libraries from my Xitomatl collection [1] (revision at
least 194 is required (and that revision has old-style file names)).

What follows are instructions for using it and an example.

Its help print-out is:

    Usage: rename-old-style directory rename-command delete-command

    Rename old-style .sls and .IMPL.sls to .r6rs-lib and .IMPL-r6rs-lib,
    also normalizing %-encoding of characters.
    Ask to remove PLT-style versions.
    Ask to rename to implicit file names.
    Ask to rename directories which may need normalizing.
    Ask to delete or rename symbolic links.

      rename-old-style a-collection mv rm
      rename-old-style a-collection "bzr mv" "bzr rm"
      rename-old-style a-collection "echo rename" "echo delete"

	A directory containing library file names to process.
	It may be renamed itself, its contents may be renamed, and it
	is recursively descended to maybe rename in its sub-directories.
	A shell command prefix which renames files.  It must take two
	arguments: the old file name and the new file name.
	A shell command prefix which deletes files.  It must take one
	argument: the file name to delete.

The below instructions are for running it on an R6RS system which does
not support SRFI 103 and uses .sls and .IMPL.sls files and does not
support implicit file names.  (It can also be run on a system which
does support SRFI 103, such as my modified Ikarus [2], if new-style
library files exist for the required libraries.)

Step 0: install pre-requisites

$ cd /path/to/search-path
$ bzr checkout --lightweight lp:~derick-eddington/scheme-libraries/xitomatl
$ bzr checkout --lightweight lp:~scheme-libraries-team/scheme-libraries/srfi
$ mkdir srfi/%3a104  # might need to be different, depending on system
$ cd srfi/%3a104
$ wget http://srfi.schemers.org/srfi-104/library-files-utilities.tar.gz
$ tar -x -z -f library-files-utilities.tar.gz

Step 1: setup (srfi :104 library-files-utilities) for use with .sls system

$ cd /path/to/srfi/%3a104
$ ln -s library-files-utilities/main.r6rs-lib library-files-utilities.sls
$ cd library-files-utilities
$ ln -s per-OS.r6rs-lib per-OS.sls
$ ln -s initialize.SYSTEM-r6rs-lib initialize.SYSTEM.sls  # replace SYSTEM

Step 2: rename a collection of library files

$ cd /path/to/search-path
$ ls -l -R %E2%99%A5%CE%BB  # only for example purposes
-rw-r--r-- %3a*poiuy.%ce%bb.sls
lrwxrwxrwx alias.ajax.sls -> qwerty-3-4.sls
drwxr-xr-x foo%3abar*zab%58blah
-rw-r--r-- foo%3abar*zab%58blah.acme.sls
-rw-r--r-- foo%3abar*zab%58blah.sls
drwxr-xr-x hoho
-rw-r--r-- hoho.sls
-rw-r--r-- qwerty-3-4.sls
-rw-r--r-- asdf.sls
-rw-r--r-- hjkl-1-2.sls
-rw-r--r-- hjkl-1-2.super.sls
lrwxrwxrwx hjkl.sls -> hjkl-1-2.sls
lrwxrwxrwx hjkl.super.sls -> hjkl-1-2.super.sls

$ scheme-script /path/to/rename-old-style.r6rs-prog %E2%99%A5%CE%BB mv rm
Rename directory %E2%99%A5%CE%BB ? [yes/no] yes
Delete symlink ♥λ/alias.ajax.sls ? [yes/no] no
Rename symlink ♥λ/alias.ajax.sls ? [yes/no] yes
Rename ♥λ/hoho.sls to implicit file name? [yes/no] no
Remove version of ♥λ/qwerty-3-4.sls ? [yes/no] no
Rename ♥λ/foo%3abar*zab%58blah.acme.sls to implicit file name? [yes/no] yes
Rename ♥λ/foo%3abar*zab%58blah.sls to implicit file name? [yes/no] yes
Rename directory ♥λ/foo%3abar*zab%58blah ? [yes/no] yes
Delete symlink ♥λ/hoho/hjkl.super.sls ? [yes/no] yes
Delete symlink ♥λ/hoho/hjkl.sls ? [yes/no] yes
Remove version of ♥λ/hoho/hjkl-1-2.super.sls ? [yes/no] yes
Remove version of ♥λ/hoho/hjkl-1-2.sls ? [yes/no] yes

$ ls -l -R ♥λ  # only for example purposes
-rw-r--r-- %3A%2Apoiuy.%ce%bb-r6rs-lib  # system name unchanged
lrwxrwxrwx alias.ajax-r6rs-lib -> qwerty-3-4.sls  # now it's a broken symlink
drwxr-xr-x foo%3Abar%2AzabXblah
drwxr-xr-x hoho
-rw-r--r-- hoho.r6rs-lib
-rw-r--r-- qwerty-3-4.r6rs-lib
-rw-r--r-- asdf.r6rs-lib
-rw-r--r-- main.acme-r6rs-lib
-rw-r--r-- main.r6rs-lib
-rw-r--r-- hjkl.r6rs-lib
-rw-r--r-- hjkl.super-r6rs-lib

Note that rename-old-style.r6rs-prog can easily be modified to rename
other extensions such as .sps to .r6rs-prog.

[1] https://code.launchpad.net/~derick-eddington/scheme-libraries/xitomatl
[2] https://code.launchpad.net/~derick-eddington/ikarus/ikarus.dev--SRFI-104

: Derick