Jump to content


Photo

Batch-rename file extensions in subfolders


  • Please log in to reply
5 replies to this topic

#1 Michel Gilbert

Michel Gilbert

    Platinum

  • Active Members
  • PipPipPipPipPip
  • 1,198 posts
  • Gender:Male
  • Accordance Version:12.x
  • Platforms:Mac OS X, iOS, Android

Posted 01 June 2018 - 01:36 PM

Hi,

 

I've been trying to batch-rename all my Notes and User Lexicon .bww files (that I copied into a separate folder) to .rtf files (so I can search them with Orbis). So far, I've tried the Terminal and Automator, and I can't figure out a way to include subdirectories.

 

In the Terminal, this works for the directory you are in:

 

for file in *.bww; do mv "$file" "${file%.txt}.rtf"; done

 

Does anyone know the syntax to include subfolders/directories as well?

 

Thanks,

 

Michel



#2 R. Mansfield

R. Mansfield

    Mithril

  • Accordance
  • 4,286 posts
  • Twitter:@thislamp
  • Gender:Male
  • Location:Louisiana
  • Interests:Biblical studies & backgrounds; Early Church writings; Eastern Orthodox theology/practice; time w/my wife, Kathy & hound, Lucy Mae; cooking w/cast iron & Tabasco; exploring in my Jeep Wrangler
  • Accordance Version:12.x
  • Platforms:Mac OS X, Windows, iOS, Android

Posted 01 June 2018 - 01:43 PM

I use A Better Finder Rename (weird name but very useful) for such things. I’m pretty sure it will do everything you’re wanting and give you a nice little interface to do it in, too. 


  • Michel Gilbert likes this

Richard Mansfield

Technology Evangelist

Accordance Bible Software

 


#3 Graham Buck

Graham Buck

    Gold

  • Accordance
  • 403 posts
  • Gender:Male
  • Location:God's Country (New England)
  • Accordance Version:12.x
  • Platforms:Mac OS X, iOS

Posted 01 June 2018 - 08:07 PM

If they are all in 1 main folder (assuming there are subfolders below, since you're asking about recursion), you can use the built-in Finder Rename function (I'm also assuming MacOS, as you've mentioned Automator).

 

https://superuser.co...ch-rename-files (the first answer)

 

Might be easier than remembering this:

find . -depth -name "\.bww" -execdir sh -c 'mv {} $(echo {} | sed "s/\.bww/.rtf/")' \;

Edited by Graham Buck, 01 June 2018 - 08:08 PM.

  • Michel Gilbert likes this

Graham Buck

iOS Programmer
Content Development [Ninja]
OakTree Software


#4 Michel Gilbert

Michel Gilbert

    Platinum

  • Active Members
  • PipPipPipPipPip
  • 1,198 posts
  • Gender:Male
  • Accordance Version:12.x
  • Platforms:Mac OS X, iOS, Android

Posted 01 June 2018 - 08:44 PM

Hi Graham,

 

Thanks.

 

I tried the built-in method before posting and I got the message, "Are you sure you want to change the extension from ".bww" to ".rtf"? . . .  and I got the choice to Keep .bww or Use .rtf. The problem is that it asks for one file at a time, and there are over 6000 of them. I didn't see an option to change them all at the same time.

 

I opened the Terminal, navigated to Documents/Notes, checked with ls, copied and pasted your syntax, and nothing happened. I'm way in over my head, perhaps I was supposed to substitute something.

 

Regards,

 

Michel



#5 Graham Buck

Graham Buck

    Gold

  • Accordance
  • 403 posts
  • Gender:Male
  • Location:God's Country (New England)
  • Accordance Version:12.x
  • Platforms:Mac OS X, iOS

Posted 01 June 2018 - 08:50 PM

hmm, it's be a while since I've done much scripting from bash. Maybe remove the '\' from in front of the first period?

find . -depth -name ".bww" -execdir sh -c 'mv {} $(echo {} | sed "s/\.bww/.rtf/")' \;

Also, not sure why I didn't suggest this above, but a free and very lightweight tool I use a bunch is PowerRenamer

 

Just search in Finder for .bww, select all, run the program and fill in the blanks. You can even do a preview to make sure the rename doesn't bork anything.


  • Michel Gilbert likes this

Graham Buck

iOS Programmer
Content Development [Ninja]
OakTree Software


#6 Michel Gilbert

Michel Gilbert

    Platinum

  • Active Members
  • PipPipPipPipPip
  • 1,198 posts
  • Gender:Male
  • Accordance Version:12.x
  • Platforms:Mac OS X, iOS, Android

Posted 01 June 2018 - 08:54 PM

 Maybe remove the '\' from in front of the first period?

 

That did it, worked perfectly. Thank you, and the Lord bless you. :)


  • Graham Buck likes this




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users