Source

XEmacs / vms / allrename.com

$! Command file to rename many files at once
$! performing a global string substitution on each name.
$!Example:
$! @allrename [...] "-" "_"
$!changes each `-' in a name into a `_'.
$!
$!The device and directory names are not altered.
$!
$	p2_length = f$length (p2)
$	p3_length = f$length (p3)
$
$file_loop:
$	   full_name = f$search("''p1'*.*;*")
$	   if ("''full_name'" .eqs. "") then goto done
$	   original_device = f$parse("''full_name'",,,"DEVICE")
$	   original_dir = f$parse("''full_name'",,,"DIRECTORY")
$	   original_file_name = f$parse("''full_name'",,,"NAME")
$	   original_file_type = f$parse("''full_name'",,,"TYPE")
$	   original_file_version = f$parse("''full_name'",,,"VERSION")
$	   original_file = original_file_name -
		+ original_file_type + original_file_version
$	   new_file = original_file
$	   something_done = "false"
$name_loop:
$	      max_length = f$length(new_file)
$	      index = f$locate("''p2'", new_file)
$	      if (index .ge. max_length) then goto end_of_name
$	      something_done = "true"
$	      new_file = f$extract (0,index,new_file) + p3 -
		+ f$extract(index+p2_length,max_length-index,new_file)
$	      goto name_loop
$end_of_name:
$	   original_file = original_device + original_dir + original_file
$	   new_file = original_device + original_dir + new_file
$	   if (something_done) then -
	      rename 'original_file' 'new_file'
$	   goto file_loop
$done:
$	exit
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.