LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-12-2014, 04:29 AM   #1
junglepunk
Member
 
Registered: Jun 2010
Posts: 41

Rep: Reputation: 15
Batch rename directories?


I need to batch rename about 600 directories using the terminal. Actually, I simply need to remove certain strings from some of them while leaving the rest of the dir names untouched.

I have tried to google this and I can find about a bazillion guides on how to batch rename files, but none concerning directories.

All the directories I need to change are located within one dir so any recursive action would be bad.

I'd really appreciate some input on this one. Thanks
 
Old 03-12-2014, 04:48 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,396

Rep: Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395
In *nix, nearly everything is treated as file where possible, including dirs.
Certainly for renaming there's no functional difference.
Definitely setup a small version of the dir layout to test on.
Depending on the complexity, I might use Perl, but its also do-able with eg bash.
Start with extremely short code and test each step as you go.
Post your code if you get stuck.
 
1 members found this post helpful.
Old 03-12-2014, 05:27 AM   #3
junglepunk
Member
 
Registered: Jun 2010
Posts: 41

Original Poster
Rep: Reputation: 15
Hi chrism01. That was really helpful actually. Basically I just picked one example I found for "files" and tried it with some test dirs. Worked perfectly. thx
 
Old 03-13-2014, 05:34 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,396

Rep: Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395
No worries: we're here to help

Glad to see you're one of the positive learners
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Rename a file in batch of directories in linux ppat18 Linux - Newbie 6 11-17-2011 03:09 PM
Batch rename files samnjugu Linux - Desktop 7 06-02-2009 10:06 AM
Batch rename troubles djeikyb Linux - General 4 07-04-2007 02:38 PM
Batch Rename shelfitz Linux - Newbie 19 10-12-2006 10:23 PM
Batch rename question hellblade Linux - Software 4 05-03-2004 03:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration