- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- file renaming
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2005 02:20 AM
тАО03-23-2005 02:20 AM
I am new to OpenVMS and wanted to know if there is a simple way to rename files. I am aware of rename command however I have filenames increasing sequentially but in different folders
e.g dir1.subdir1.filename
dir2.subdir2.filename
dir3.subdir3.filename
Can anyone please let me know how to rename the filenames with a simple script
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2005 02:38 AM
тАО03-23-2005 02:38 AM
Re: file renaming
you can do things with wildcarded renames otherwise a simpile loop in DCL
$C=1
$L1:
$ IF C .LT. 10 THEN GOTO END
$ RENAME [DIR'C'.SUBDIR'C']FILENAME NEWNAME
$ C = C+ 1
$ GOTO L1
$END:
I expect Hein will come up with a solution in perl :-)
Purely Personal Opinion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2005 03:00 AM
тАО03-23-2005 03:00 AM
Re: file renaming
some simple examples:
rename all files from [DIR.SUB] to [DIR]
(one level up)
$ RENA [DIR.SUB]*.*.* [DIR]
rename the highest version of each file:
$ RENA [DIR2.XYZ]*.*;0 [DIR3.ABC.DEF]
Renane alle files except those created todat:
$ RENA [X.Y]*.*.* [A.B.C]/BEFORE=TODAY
rename all files modified the last week:
$ RENA [A.B]*.*.* [C.D.E.F]/MODIFIED/SINC="TODAY-7-"
Rename all (but only the) .XYZ files:
$ RENA [P]*.XYZ.* [Q.R]
Rename all files with PQR somewhere in the filename:
RENA [X]*PQR*.*;* [Y.Z]
If you have more complex needs, then in a DCL script just about anything can be accompliced. Tell us your need, and we will come up with an example solution.
You can work out your own needs.
Beware:
unlike UNIX, in VMS you can ONLY rename files to a location on THE SAME PHYSICAL DISK DRIVE!
hth
Proost.
Have one on me.
Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2005 03:04 AM
тАО03-23-2005 03:04 AM
Re: file renaming
your script will not do much!!
C=1
If C is less than 10 go to end.....
which will very quickly be over, and nothing gets done :-(
This sure makes it easy for Hein to come up with something better!
I guess you meant
$ IF C . GT. 10 THEN ...
Proost.
Have one on me.
jpe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2005 03:33 AM
тАО03-23-2005 03:33 AM
Re: file renaming
Just a typo.
Purely Personal Opinion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2005 03:39 AM
тАО03-23-2005 03:39 AM
Re: file renaming
I have two objectives 1) Rename files (*.ABC)
2) Move (*.TXT) files
In both the scenario the directory setup is
as shown below. Right now I will go with first object, 2nd one I will post as new thread if required
Please Note: these are two separate files in each directory with .GOBJ extension
[00000760.00000427]C0000385.GOBJ
[00000760.00000427]C0000385_TRAB.GOBJ
[00000761.00000428]C0000386.GOBJ
[00000761.00000428]C0000386_TRAB.GOBJ
[00000763.00000429]C0000387.GOBJ
[00000763.00000429]C0000387_TRAB.GOBJ.
.
.
.
Please observe the difference in numbers between 2nd and 3rd DIRECTORIES....
The following is the renaming
$RENAME C0000385.GOBJ C0000385_full.GOBJ
$RENAME C0000385_TRAB.GOBJ C0000385.GOBJ
The following things are constant
1) No change in strings
2) The files are always located two subdirectories below as shown in the above example
3) File numbers can range from 0000000 to 999999 (right now we have files till 00008000)with a string before e.g C0000499.GOBJ
My point is I am looking for 2 options in script that works like this
Option 1: Sequential Increase
Enter your starting file number: 385 (this is directly the .Gobj file number shown above)
Enter you ending file number: 402
Option2: Non sequential increase
In this scenarion I am thinking of preparing a txt file or editing the COM file and writing down each *.GOBJ number eg from which it can be read.
$!enter the file names beow
335
345
402
454
$End
let me know your suggestions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2005 06:12 AM
тАО03-23-2005 06:12 AM
SolutionIt can not morph a file name or extension.
Here is a coarse outline with examples.
First in PERL, then in DCL.
First create some test files:
$ cr/dir [.tmp.a]
$ cr/dir [.tmp.b]
$ cr/dir [.tmp.c]
$ cop nl: [.tmp.a]001.tmp
$ cop nl: [.tmp.a]002.tmp
$ cop nl: [.tmp.a]003.tmp
$ cop nl: [.tmp.b]003.tmp
$ cop nl: [.tmp.b]004.tmp
$ cop nl: [.tmp.b]005.tmp
$ cop nl: [.tmp.c]006.tmp
List them in perl with a one-liner:
$ perl -e "print ""$_\n"" foreach (<[.tmp.*]*.tmp>)"
u$1:[hein.tmp.a]001.tmp
u$1:[hein.tmp.a]002.tmp
u$1:[hein.tmp.a]003.tmp
u$1:[hein.tmp.b]003.tmp
u$1:[hein.tmp.b]004.tmp
u$1:[hein.tmp.b]005.tmp
u$1:[hein.tmp.c]006.tmp
Here is a perl one-liner for rename:
perl -e "foreach (<[.tmp.*]*.tmp>){ if (/(.*)\.(.*)/) { rename $_,$1.""_xxx."".$2 }}"
- the same 'glob' operation to find target files.
- then a regular expression to look for anytinng it can up to the last period (the * is greedy) remember that (in $1), and remember everything after that last period in $2.
- call rename with the file glob line ($_) as first argument, and a constructed second argument.
You could readily tweak the glob file spec, or the regexpr to match exactly those files needed.
Now a DCL loop to get the files:
$ cre tmp.com
$loop:
$file = f$search ("[.tmp.*]*.tmp")
$if file .eqs. "" then goto done
$write sys$output file
$goto loop
$done:
Exit
$ @tmp
U$1:[HEIN.TMP.A]001_XXX.TMP;1
U$1:[HEIN.TMP.A]002_XXX.TMP;1
U$1:[HEIN.TMP.A]003_XXX.TMP;1
U$1:[HEIN.TMP.B]003_XXX.TMP;1
U$1:[HEIN.TMP.B]004_XXX.TMP;1
U$1:[HEIN.TMP.B]005_XXX.TMP;1
U$1:[HEIN.TMP.C]006_XXX.TMP;1
And a DCL loop to do similar renames:
$ cre tmp.com
$loop:
$file = f$search ("[.tmp.*]*.tmp")
$if file .eqs. "" then goto done
$new_name = f$parse(file,,,"name") + "_yyy"
$rename/log 'file 'new_name
$goto loop
$done:
Exit
$ @tmp
%RENAME-I-RENAMED, U$1:[HEIN.TMP.A]001_XXX.TMP;1 renamed to U$1:[HEIN.TMP.A]001_XXX_YYY.TMP;1
%RENAME-I-RENAMED, U$1:[HEIN.TMP.A]002_XXX.TMP;1 renamed to U$1:[HEIN.TMP.A]002_XXX_YYY.TMP;1
%RENAME-I-RENAMED, U$1:[HEIN.TMP.A]003_XXX.TMP;1 renamed to U$1:[HEIN.TMP.A]003_XXX_YYY.TMP;1
%RENAME-I-RENAMED, U$1:[HEIN.TMP.B]003_XXX.TMP;1 renamed to U$1:[HEIN.TMP.B]003_XXX_YYY.TMP;1
%RENAME-I-RENAMED, U$1:[HEIN.TMP.B]004_XXX.TMP;1 renamed to U$1:[HEIN.TMP.B]004_XXX_YYY.TMP;1
%RENAME-I-RENAMED, U$1:[HEIN.TMP.B]005_XXX.TMP;1 renamed to U$1:[HEIN.TMP.B]005_XXX_YYY.TMP;1
%RENAME-I-RENAMED, U$1:[HEIN.TMP.C]006_XXX.TMP;1 renamed to U$1:[HEIN.TMP.C]006_XXX_YYY.TMP;1
Enjoy!
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-23-2005 05:10 PM
тАО03-23-2005 05:10 PM
Re: file renaming
I once wrote a little utility for 'enhanced' renaming, Heins example would be:
$ xren <.%>%%%.tmp ()_YYY
The help (XREN ?) is in german, but in the beginning are some english comments.
mfg Kalle
P.S. I renamed it to .COM_TXT.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-24-2005 05:51 AM
тАО03-24-2005 05:51 AM
Re: file renaming
That was awesome. I got things running pretty well. Ofcourse, there are some modifications I still have to do. But that script pretty much did everything I need to know.
The script by Ian was also very helpful for file renaming.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-24-2005 01:35 PM
тАО03-24-2005 01:35 PM
Re: file renaming
I have already developed the file as per Hein's script and thereby also got better understanding of DCL programming. Your utility file will definetely be useful as a learning experience.
nipun