Removing . from beginning of files

Post any Bulk Rename Utility support requirements here. Open to all registered users.

Removing . from beginning of files

Postby simong84 » Tue Jul 02, 2019 5:54 pm

Hi All

I have a folder full of sub folders and within those, some files that have . at the beginning.

Would someone please tell me the best way to run through all sub folders and remove any leading . or replace them with _ ?

Thanks

Simon
simong84
 
Posts: 2
Joined: Tue Jul 02, 2019 5:51 pm

Re: Removing . from beginning of files

Postby therube » Tue Jul 02, 2019 7:59 pm

Select your parent folder.

12:Filters -> Subfolders (if need, seems you do)

3:Replace
.
with
<leave blank>

Looks like it should work:

._namespace.js ---> _namespace.js
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Removing . from beginning of files

Postby simong84 » Tue Jul 02, 2019 9:49 pm

Thanks for the reply.

The problem is, we don't want to replace all dots - only any that are the first character on the file path.

We are uploading onto SharePoint and it doesn't like it if a . is the first character but they can exist elsewhere in the file name.
simong84
 
Posts: 2
Joined: Tue Jul 02, 2019 5:51 pm

Re: Removing . from beginning of files

Postby therube » Wed Jul 03, 2019 1:39 am

Heh, oh.

And when I searched on my end for files that started with ., my search was (in Everything) regex:^\.

So... in BRU try this instead of 3:Replace:

1:RegEx
Code: Select all
Match:  (^\.)(.*)
Replace:  \2
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Removing . from beginning of files

Postby Admin » Wed Jul 03, 2019 1:50 am

With Javascript Renaming in Bulk Rename Utility:

Code: Select all
if (name.charAt(0) == ".") newName = name.substring(1);


the above script removes the . in the first position.

Or to replace with _ :

Code: Select all
if (name.charAt(0) == ".") newName = "_" + name.substring(1);
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm


Return to BRU Support