- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script to rename multiple file names
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
тАО11-12-2008 02:36 AM
тАО11-12-2008 02:36 AM
script to rename multiple file names
I have a directory which has filenames with extension .amt;1 (e.g one file name is sgho11.amt;1 and another filename is sgho12.amt;1). Can you please let me know how can I rename all the files with extension .amt1.
Thanks in advance
Gab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2008 03:23 AM
тАО11-12-2008 03:23 AM
Re: script to rename multiple file names
Side note: Looks like wherever you got these files you didn't mount the media properly.
I'm not sure after the rename you will have usable files. It might be better to properly mount the media and copy the files to disk properly.
ls -1 > list
while read -r fn
do
# add a line to calculate the new name.
mv $fn $newname
done < list
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2008 04:51 AM
тАО11-12-2008 04:51 AM
Re: script to rename multiple file names
You are going to have to quote $fn since it has a ";":
mv "$fn" $newname
Some threads to compute $newname:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1261895
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=218443
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=938720
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2008 05:39 AM
тАО11-12-2008 05:39 AM
Re: script to rename multiple file names
Please try below.
for file in `ls -1`
> do
> mv $file `echo $i|awk -F. '{print $1}'`.amt1
> done
Thanks
Sen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2008 07:58 AM
тАО11-12-2008 07:58 AM
Re: script to rename multiple file names
for i in $(ls)
do
mv $i ${i%%;1}1
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2008 01:52 PM
тАО11-12-2008 01:52 PM
Re: script to rename multiple file names
Oops, it appears the shell scans for ";" before it does parm substitution. So only whitespace needs to be quoted.