- 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
Forums
Discussions
Discussions
Discussions
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2009 01:48 PM
01-23-2009 01:48 PM
Re: renaming files help
I'm getting somewhere with this now
The BENIN files are now showing as
BENIN.10
BENIN.11
BENIN.12
BENIN.14
That was using
$loop:
$ next = f$search("benin.*")
$ if next .eqs. "" then goto done
$ ext = f$parse(next,,,"type") - "."
$ 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:
Unfortunately for the program to process these files they need the .0 before the extention
ie
BENIN.010
BENIN.011
I think I'm going to have to do a bit of research into this tonight.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2009 02:13 PM
01-23-2009 02:13 PM
Re: renaming files help
Ok, with all due respect to Jan and Hein, this is why I try not to post code more than a line or so in length.
It is VERY dangerous to run code WITHOUT knowing precisely how it functions. It is easy to run something using CUT/PASTE that can cost dearly (I do presume that the directory was backed up BEFORE running this procedure).
The line:
nwext = ext - 300
Will subtract 300 from the number. The default for numeric->string conversion in DCL is the minimum number of digits.
In this instant case of all the numbers being between 300 and 399 inclusive, the problem can be corrected by changing the RENAME command:
$ rename 'next' *.'nwext
to
$ rename 'next' *.0'nwext
For a more general fix, one will need to look up the F$FAO lexical function and use the formatting options to reformat the name in whatever format is desired (e.g., hex, octal, decimal). One can also do other transformations as needed, if one wants to be more creative.
- Bob Gezelter, http://www.rlgsc.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2009 02:35 PM
01-23-2009 02:35 PM
Re: renaming files help
I really have learned a lot tonight
My problem has now been solved thanks to the help from all of you.
All files are now ready for processing (I did experiment on some test files that I created earlier)
I owe you all a pint.
When time allows I must learn some more DCL.
Incidenatally what kind of systems are you guys using?
We have a load of VAX 4000 machines
Bye for now
BM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2009 10:13 PM
01-23-2009 10:13 PM
Re: renaming files help
Glad to be of assistance!
VAX 4000 systems are one of the later generations of VAX systems.
In my lab, my systems range from MicroVAX II systems up through Alpha to Itanium.
Since DCL is the native scripting and command language, it is very useful. The best information is in the documentation set. Recent versions are available under "Documentation" at http://www.hp.com/go/openvms
While some details of DCL have been extended since the last VAX release, the language as a whole has been completely stable for a LONG time.
- Bob Gezelter, http://www.rlgsc.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2009 05:22 AM
01-24-2009 05:22 AM
Re: renaming files help
>>>
I owe you all a pint.
<<<
Thank you very much. At the time you wrote that, I was having a Grimbergen Triple. For those who do not know: the Monastry of the Belgian village Grimbergen founded a brewery in 1128 (yes, nearly 900 years ago!)
The Triple is a high-fermenting yellow beer with a lot of body ("Stammwuerze") and 9% EtOH.
But on expressing your thanks in the Forum, please review
http://forums1.itrc.hp.com/service/forums/helptips.do?#33
Proost.
Have one on me.
jpe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2009 05:26 AM
01-24-2009 05:26 AM
Re: renaming files help
>>>
Incidenatally what kind of systems are you guys using?
<<<
I have 2 Alpha 1000 systems at home. (plus 2 Vax 3100, but those have not seen any electricity since I moved in 2001, so they probably don't count)
Proost.
Have one on me.
jpe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2009 07:08 AM
01-24-2009 07:08 AM
Re: renaming files help
Jan> Thank you very much. At the time you wrote that, I was having a Grimbergen Triple
And I was enjoying a Shipyard seasonal (Prelude). I had a Grimbergen earlier this month.. in Eindhoven. Not my favourite, but I keep trying. Maybe some day.
For abbey beers I stick to the 'dubbel' (La Trappe). Martha's Exchange here in Nashua has a reasonable version of it on draft right now.
Ben>> Incidenatally what kind of systems are you guys using?
I 'tested' your request on my RX2620 Itanium.
In my lab I have a VaxStation 4000/60(?), 2xDS10, rx2620, rx2600, msa1000+14drives, 16/2 fibreswitch, 24xGigabit network, Decserver90m, BA356, DS2100, DL380, Linux ThinClient as 'terminal' for consoles/webbrowsing. Ebay!
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2009 01:32 AM
01-26-2009 01:32 AM
Re: renaming files help
I was having a bottle of Adnams Broadside (Suffolk Ale)when the file renames had completed.
I'm familiar with Grimbergen beers, they can be found from time to time in shops & bars here (have only tried the one with the yellow label). I really like those Abbey beers. I want to try them all.
Cheers Guys