Page 1 of 1

How do I add or remove spaces from filenames?

PostPosted: Sun Oct 09, 2016 7:26 am
by PaulL
I just installed your program. I would like to selectively add or remove spaces in all files in an extensive directory tree.

For example I would like to filter the tree for files matching *f*.xxx and then replace all filenames like
Code: Select all
*fqq.xxx
with
Code: Select all
* fqq.xxx
by adding a space before the "f" in each filename, or replace all filenames like
Code: Select all
*  fqq.xxx
with
Code: Select all
* fqq.xxx
by removing one of the two spaces before the "f" in each filename.

Re: How do I add or remove spaces from filenames?

PostPosted: Sun Oct 09, 2016 4:40 pm
by therube
12:Filter
Code: Select all
Mask:  fqq\.
RegEx
Subfolders


3:Replace
Code: Select all
Replace:  fqq
With:  {space}fqq


---

If it's always (two) spaces:
Code: Select all
3:Replace
Replace:  {space}{space}
With:  {space}


If it's potentially more then two spaces:
12:RegEx
Code: Select all
Match:  (\S*)\s*(\S*)
Replace:  \1 \2

(Not entire sure about any of them, so check things out first ;-).)

Re: How do I add or remove spaces from filenames?

PostPosted: Sun Oct 09, 2016 7:31 pm
by KenP
This should work whether or not there are spaces immediately before the fqq and regardless of how many there are, it should also work if there are spaces elsewhere in the file name.

Filter (12)
Mask: fqq\.
Regex: selected
Subfolders: selected

Regex (1)
Match: (.*)(\w)(| | | *)(fqq)
Replace: \1\2 \4

Edit: I've just realised that the Regex Match can be simplified to Match: (.*)(\w)( *)(fqq)

Re: How do I add or remove spaces from filenames?

PostPosted: Sun Oct 09, 2016 11:45 pm
by PaulL
Thank you.
Using 12:Filter mask:F\. RegEx Subfolders produce a list of files.
Then I selected all the displayed files with Ctrl+A.
Then Using 3:Replace mask:F with:{space}F seems to work.