The FreeBSD Diary

The FreeBSD Diary (TM) Remember
I remember
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]

Scripts / handy tips
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 Renaming some directories
Author: Dan 
Date:   30-11-06 13:47

I needed some directories renamed. Tendogs answered my request for a script:

[dan@nyi:~/tmp/adsl] $ rm *
[dan@nyi:~/tmp/adsl] $ ls
[dan@nyi:~/tmp/adsl] $ touch `ls /usr/websites/unixathome.org/www/adsl/archives.backups/`


The above line creates test data without copying the actual directories. In all, there are 25,000 files in there, and I didn't want to copy them all over.


[dan@nyi:~/tmp/adsl] $ ls
adsl.archive.0001 adsl.archive.0102 adsl.archive.0203 adsl.archive.0304 adsl.archive.0405 adsl.archive.0506 adsl.archive.0609
adsl.archive.0002 adsl.archive.0103 adsl.archive.0204 adsl.archive.0305 adsl.archive.0406 adsl.archive.0507 adsl.archive.0610
adsl.archive.0003 adsl.archive.0104 adsl.archive.0205 adsl.archive.0306 adsl.archive.0407 adsl.archive.0508 adsl.archive.0611
adsl.archive.0004 adsl.archive.0105 adsl.archive.0206 adsl.archive.0307 adsl.archive.0408 adsl.archive.0509 adsl.archive.8001
adsl.archive.0005 adsl.archive.0106 adsl.archive.0207 adsl.archive.0308 adsl.archive.0409 adsl.archive.0510 adsl.archive.9904
adsl.archive.0006 adsl.archive.0107 adsl.archive.0208 adsl.archive.0309 adsl.archive.0410 adsl.archive.0511 adsl.archive.9905
adsl.archive.0007 adsl.archive.0108 adsl.archive.0209 adsl.archive.0310 adsl.archive.0411 adsl.archive.0512 adsl.archive.9906
adsl.archive.0008 adsl.archive.0109 adsl.archive.0210 adsl.archive.0311 adsl.archive.0412 adsl.archive.0601 adsl.archive.9907
adsl.archive.0009 adsl.archive.0110 adsl.archive.0211 adsl.archive.0312 adsl.archive.0501 adsl.archive.0602 adsl.archive.9908
adsl.archive.0010 adsl.archive.0111 adsl.archive.0212 adsl.archive.0401 adsl.archive.0502 adsl.archive.0603 adsl.archive.9909
adsl.archive.0011 adsl.archive.0112 adsl.archive.0301 adsl.archive.0402 adsl.archive.0503 adsl.archive.0604 adsl.archive.9910
adsl.archive.0012 adsl.archive.0201 adsl.archive.0302 adsl.archive.0403 adsl.archive.0504 adsl.archive.0605 adsl.archive.9911
adsl.archive.0101 adsl.archive.0202 adsl.archive.0303 adsl.archive.0404 adsl.archive.0505 adsl.archive.0608 adsl.archive.9912
[dan@nyi:~/tmp/adsl] $ for A in adsl.archive.*; do C=${A%.*};B=${A##*.};MON=${B#??};YEAR=${B%??};q=1900;[ $YEAR -le 7 ] && q=2000;YEAR=$(($YEAR + $q)); mv $A ${YEAR}_$MON;done
[dan@nyi:~/tmp/adsl] $ ls
1980_01 1999_08 2000_01 2000_06 2000_11 2001_04 2001_09 2002_02 2002_07 2002_12 2003_05 2003_10 2004_03 2004_08 2005_01 2005_06 2005_11 2006_04 2006_11
1999_04 1999_09 2000_02 2000_07 2000_12 2001_05 2001_10 2002_03 2002_08 2003_01 2003_06 2003_11 2004_04 2004_09 2005_02 2005_07 2005_12 2006_05
1999_05 1999_10 2000_03 2000_08 2001_01 2001_06 2001_11 2002_04 2002_09 2003_02 2003_07 2003_12 2004_05 2004_10 2005_03 2005_08 2006_01 2006_08
1999_06 1999_11 2000_04 2000_09 2001_02 2001_07 2001_12 2002_05 2002_10 2003_03 2003_08 2004_01 2004_06 2004_11 2005_04 2005_09 2006_02 2006_09
1999_07 1999_12 2000_05 2000_10 2001_03 2001_08 2002_01 2002_06 2002_11 2003_04 2003_09 2004_02 2004_07 2004_12 2005_05 2005_10 2006_03 2006_10
[dan@nyi:~/tmp/adsl] $

--
Webmaster

Post Edited (30-11-06 08:54)

Reply To This Message
 Forum List  |  Threaded View   Newer Topic  |  Older Topic 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org