Microsoft
Software
Hardware
Network
Question : Need script to traverse directories and rename them.
Experts,
I've been attempting to create this script with no luck.
Here are the objectives.
1) search the operating system for specific directory names.
2) rename those directories.
So far I've tried the following to find the files.
find / -type d | grep "XYZ" | grep -v "BACKUP"
eveything I've tried to place after the above argument wont do just a regex replace of the matching directory name it wants to do the whole thing.
I've also tried putting the output of the find command into a file to then rename the directories there but no luck.
Here is a sample of the directory structure that I have to change...
/u08/foo/XYZ
/u04/foo/XYZ
/u06/foo/XYZ
/Data/exp/DB12/XYZ
/u01/app/foo/oradba/migrat
ion/XYZ
/u01/app/foo/admin/XYZ
/u01/app/foo/admin/XYZ/bdu
mp
/u01/app/foo/admin/XYZ/cdu
mp
/u01/app/foo/admin/XYZ/udu
mp
/u01/app/foo/admin/XYZ/pfi
le
/u01/app/foo/admin/XYZ/cre
ate
/u01/app/foo/admin/XYZ/log
/u05/foo/XYZ
/u03/foo/XYZ
/u07/foo/XYZ
Answer : Need script to traverse directories and rename them.
1:
find / -type -name "*XYZ" -a ! -name "*BACKUP*" -exec mv {} {}_OLD \; 2>/dev/null
Open in New Window
Select All
Random Solutions
Optimizing a MySQL query that uses filesort
norton ghost 10.0 Error EC8F17B7: Cannot create recovery points for job Error EA390719: Target disk full
Problems loading Acer drivers
Find all the printers installed on all the machines in the file
Question using remote desktop connection to a Windows Server
error 1053
Windows 7 Explorer.exe runas not working
Exchange 2007 Backup Exec 11d
ajax loader
Using javascript function check, how do I code a form page that forces the user to click one of the radio buttons before sending the page?