GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   how to bulk change names in directory of centos server? (https://gfy.com/showthread.php?t=1081383)

roly 09-13-2012 08:26 AM

how to bulk change names in directory of centos server?
 
hi

i've got a folder with 1000+ text files in it, does anyone know what i can type on the command line (maybe a perl command or something?) to change the name slightly e.g.

old file names: file062012.sitename.net.txt file77582.sitename.net.txt etc

new file names: file062012.www.sitename.net.txt file77582.www.sitename.net.txt

thanks in advance

DamageX 09-13-2012 08:30 AM

rm -rf *

Colmike9 09-13-2012 08:32 AM

rename sitename www.sitename *

or

$ rename 's/sitename/www.sitename/' *

roly 09-13-2012 08:32 AM

Quote:

Originally Posted by DamageX (Post 19187063)
rm -rf *

are you sure, can you test it on your server first?

DamageX 09-13-2012 08:36 AM

Quote:

Originally Posted by roly (Post 19187066)
are you sure, can you test it on your server first?

Done. It's safe, you can go ahead now.

roly 09-13-2012 08:41 AM

Quote:

Originally Posted by DamageX (Post 19187075)
Done. It's safe, you can go ahead now.

didn't work, but as a bonus i have a lot more space on my HD, thanks for your help :thumbsup

roly 09-13-2012 08:41 AM

Quote:

Originally Posted by Colmike7 (Post 19187065)
rename sitename www.sitename *

or

$ rename 's/sitename/www.sitename/' *

just having a play with that now, thanks

DamageX 09-13-2012 08:41 AM

Quote:

Originally Posted by roly (Post 19187086)
didn't work, but as a bonus i have a lot more space on my HD, thanks for your help :thumbsup

Happy to help. :)

Colmike9 09-13-2012 08:46 AM

Quote:

Originally Posted by roly (Post 19187089)
just having a play with that now, thanks

Hope it works. I think the first one works just for CentOS 5.5, but I might be wrong. The second is the Debian / Ubuntu perl version of rename. Use YMMV if you're using another distro or OS. :winkwink:


All times are GMT -7. The time now is 08:53 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123