| | |
File ext rename
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Aug 2006
Posts: 3
Reputation:
Solved Threads: 0
PQPZ3.DATR.QRL.R9529.D090295.T19501.das.1333332287722.1.2.err
I have AIX so I can't use rename hopeing for something easier but I need to find all the files in the directory and then any of them that have a .err on them I need to be able to rename them back all the way to the .das
So I need to go from
PQPZ3.DATR.QRL.R9529.D090295.T19501.das.1333332287722.1.2.err
to
PQPZ3.DATR.QRL.R9529.D090295.T19501.das
When I have many .err's one quick script to rename them all back to the .das
I have AIX so I can't use rename hopeing for something easier but I need to find all the files in the directory and then any of them that have a .err on them I need to be able to rename them back all the way to the .das
So I need to go from
PQPZ3.DATR.QRL.R9529.D090295.T19501.das.1333332287722.1.2.err
to
PQPZ3.DATR.QRL.R9529.D090295.T19501.das
When I have many .err's one quick script to rename them all back to the .das
•
•
Join Date: May 2004
Posts: 178
Reputation:
Solved Threads: 10
You have to use either ksh (zsh) or bash to do this - ie., a modern shell with pattern matching.
Test it somewhere first!
Shell Scripting Syntax (Toggle Plain Text)
cd /path/to/files find . -name '*.err' |\ while read file do tmp=${file%%.das*} mv $file "$file".das done
Test it somewhere first!
Change
mv $file "$file".das to mv $file ${tmp}.das. It was just a typo. Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
- Virus scanner file(php) cannot be executed (PHP)
- Error 624: The system could not update the phone book file (Windows NT / 2000 / XP)
- Deleting from Random Access File? (VB.NET)
- need help... how to file open client path text.. (PHP)
- How to Rename Multiple Files with Windows Explorer (Windows tips 'n' tweaks)
Other Threads in the Shell Scripting Forum
- Previous Thread: Will Pay $20 Paypal: Script Help ASAP
- Next Thread: Need a shell script for rsync
| Thread Tools | Search this Thread |
Tag cloud for Shell Scripting






