- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Rename a number of files
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
тАО06-08-2009 11:07 PM
тАО06-08-2009 11:07 PM
Rename a number of files
I would like to rename a number of files located in the same directory from *job to *job.date
Is it possible?
Regards
Feng Lin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2009 11:21 PM
тАО06-08-2009 11:21 PM
Re: Rename a number of files
Please check the link
http://www.informatik.uni-frankfurt.de/doc/man/hpux/mv.1.html
thanks and regards
Sajjad Sahir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2009 11:26 PM
тАО06-08-2009 11:26 PM
Re: Rename a number of files
This will do: ( Please Check it)
Change the date format if you wish to..
for I in `ls -1 *.job`
do
mv ${I} ${I}.`date "+%Y%m%d"`
done
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2009 11:29 PM
тАО06-08-2009 11:29 PM
Re: Rename a number of files
I would like to do it in 1 command line. This means I want a number of files with extension .job to change to .job.date
Any such commands?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2009 11:33 PM
тАО06-08-2009 11:33 PM
Re: Rename a number of files
this is a little difft
for file in *
do
mv ${file} ${file}.`date "+%Y%m%d"`
done
are you trying to move entire dirs or is this in one dir.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2009 11:35 PM
тАО06-08-2009 11:35 PM
Re: Rename a number of files
was wondering whether it can be done in 1 command line.
Cheers
Feng Lin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2009 01:58 AM
тАО06-09-2009 01:58 AM
Re: Rename a number of files
Please try the below 2 commands
find /dir -type f -name "*job" -print |xargs -t -I {} mv {} {}.date
cd /dir
ls |xargs -t -I {} mv {} {}.date
Sagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-09-2009 03:44 AM
тАО06-09-2009 03:44 AM
Re: Rename a number of files
Only if you write your own script/command.
Why do you care? You want something you can understand/maintain.
>Nido: mv ${I} ${I}.`date "+%Y%m%d"`
It might be a good idea to get the date once before the loop.
t_stamp=$(date "+%Y%m%d")
for I in *.job; do
mv ${I} ${I}.$t_stamp
done