annotate vms/allrename.com @ 23:0edd3412f124

Added tag r19-15b94 for changeset 8fc7fe29b841
author cvs
date Mon, 13 Aug 2007 08:50:31 +0200
parents 376386a54a3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 $! Command file to rename many files at once
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 $! performing a global string substitution on each name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 $!Example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 $! @allrename [...] "-" "_"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 $!changes each `-' in a name into a `_'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 $!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 $!The device and directory names are not altered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 $!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 $ p2_length = f$length (p2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 $ p3_length = f$length (p3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 $
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 $file_loop:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 $ full_name = f$search("''p1'*.*;*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 $ if ("''full_name'" .eqs. "") then goto done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 $ original_device = f$parse("''full_name'",,,"DEVICE")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 $ original_dir = f$parse("''full_name'",,,"DIRECTORY")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 $ original_file_name = f$parse("''full_name'",,,"NAME")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 $ original_file_type = f$parse("''full_name'",,,"TYPE")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 $ original_file_version = f$parse("''full_name'",,,"VERSION")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 $ original_file = original_file_name -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 + original_file_type + original_file_version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 $ new_file = original_file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 $ something_done = "false"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 $name_loop:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 $ max_length = f$length(new_file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 $ index = f$locate("''p2'", new_file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 $ if (index .ge. max_length) then goto end_of_name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 $ something_done = "true"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 $ new_file = f$extract (0,index,new_file) + p3 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 + f$extract(index+p2_length,max_length-index,new_file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 $ goto name_loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 $end_of_name:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 $ original_file = original_device + original_dir + original_file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 $ new_file = original_device + original_dir + new_file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 $ if (something_done) then -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 rename 'original_file' 'new_file'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 $ goto file_loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 $done:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 $ exit