- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- renaming files help
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
тАО01-23-2009 11:43 AM
тАО01-23-2009 11:43 AM
I'm after some help in renaming files on a VMS/ VAX system.
The files are called
Benbad.310;1
Benbad.311;1
Benbad.312;1
Benbad.314;1
.....and so on
There are about 300 or so files.
I want to rename them to
Benin.010;1
Benin.011;1
Benin.012;1
Benin.014;1
....and so on (relace the 3 to a 0)
I have tried rename Benbad.3*;1 to Benin.0*;1
but it comes up with 'error opening file Benin.0*; as output
Anyone know of a way of renaming the whole lot of files easily? I don't really want to rename each one one at a time as it'll take ages.
Many thanks in advance
BM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2009 12:02 PM
тАО01-23-2009 12:02 PM
Solutionto begin with:
WELCOME to the VMS forum!
For your problem, I would create a small DCL command file.
$loop:
$ next = f$search("benbad.*")
$ if next .eqs. "" then goto done
$ ext = f$parse(next,,,"extention") - "."
$ if f$type(ext) .nes. "INTEGER" then goto done
$ if ext .lt. 300 then goto done
$ nwext = ext - 300
$ rename 'next' *.'nwext
$ goto loop
$done:
Explanation:
-find the next file called benbad -- any extension
-get its extension, but remove the "."
-test it for being a number
-if it is less than 300 you may have restarted (check this for validity in your environment; might need to change to GOTO LOOP)
- subtract 100
- rename
- repeat
hth
Proost.
Have one on me.
jpe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2009 12:05 PM
тАО01-23-2009 12:05 PM
Re: renaming files help
I would write a small DCL script to iterate through the directories using F$SEARCH, then F$PARSE to break the resulting filenames into their component pieces, then constructing the desired filename. Finally use the RENAME command to actually rename from the old file to the new file.
You may find my presentation on DCL Lexical functions from the Fall 1995 DECUS Symposium useful (the PDF of the slides can be found at http://www.rlgsc.com/decus/usf95/index.html ).
- Bob Gezelter, http://www.rlgsc.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2009 12:06 PM
тАО01-23-2009 12:06 PM
Re: renaming files help
Many thanks for the quick reply. I'll give this a go and let you know how I get on.
Cheers
Ben
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2009 12:08 PM
тАО01-23-2009 12:08 PM
Re: renaming files help
I'll take a look at that.
Cheers guys
Ben
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2009 12:08 PM
тАО01-23-2009 12:08 PM
Re: renaming files help
You can go the DCL route with an F$SEARCH in a loop, pick apart the filename (f$PARSE) and rename or... use PERL.
$! dir be*
Benbad.310;1 Benbad.311;1 Benbad.312;1 Benbad.314;1
$ ! Always do a dry-run:
$ perl -e "for (
benbad.310 benbad.010
benbad.311 benbad.011
benbad.312 benbad.012
benbad.314 benbad.014
$ ! Now for real...
$ perl -e "for (
$ dir be*
benbad.010;1 benbad.011;1 benbad.012;1 benbad.014;1
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2009 12:19 PM
тАО01-23-2009 12:19 PM
Re: renaming files help
For me this is one of the most use perl 'one-liner' in my personal repetoir :-).
For those who are not too familiar with perl but intersted some, here is that command in slow motion:
perl -e ! Command to follw in string
for () ! Loop over some array returning
! elements into default variable $_
{ ! Block open
$o = $_; ! copy $_ into $o (old name)
s/\.3/.0/; ! Substitute .3 with a .0
! Escape the period as it is a wildcard.
rename $o,$_ ! Function to do the deed
} ! Block Done, loop around
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2009 01:07 PM
тАО01-23-2009 01:07 PM
Re: renaming files help
I think I'm going to have to use the DCL script method here as PERL is not installed on our VAX.
You are going to have to forgive me a bit here as I am pretty new to VMS and programming. I'm understanding the general idea of how the f$search & parse are operating.
I have created the DCL script and called it rename.com. Whenever I try to run it I'm getting
@rename
%DCL-W-IVKEYW, unrecognized keyword - check validity and spelling
\EXTENSION\
I'm obviously doing something basic wrong here.
Thanks
Ben
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2009 01:15 PM
тАО01-23-2009 01:15 PM
Re: renaming files help
Ben,
Check out: $help lexi f$parse arg
Jan wrote: $ ext = f$parse(next,,,"extention") - "."
Jan meant: $ ext = f$parse(next,,,"TYPE") - "."
Jan's solution uses integer calculation.
Thje description of your problem suggested STRING manipulation to me.
Suggested code ('works for me' :-)
$loop:
$ next = f$search("benbad.*")
$ if next .eqs. "" then goto done
$ ext = f$parse(next,,,"TYPE") - ".3"
$ rename/log 'next' .0'ext
$ goto loop
$done:
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2009 01:29 PM
тАО01-23-2009 01:29 PM
Re: renaming files help
Hein (Hi Hein, still sorry for missing our bridge appointment because of medical reasons last year, all the more since bootcamp for 2009 is cancelled!) is right of course.
My bad, I did not check the docs.
As for Hein's variant:
- ANY extension starting with the digit 3 would also be done, such as .3ABC, any in the 30's, any 3000's, any 30000's.
- my solution will also rename 4nn to 1nn, 5nn to 2nn, etc.
Check which is relevant to you!!
hth
Proost.
Have one on me.
jpe