Renaming default Windows File Manager copies

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
ilexedits
Posts: 8
Joined: 19 Aug 2017 18:04

Renaming default Windows File Manager copies

Post by ilexedits »

Sorry to be dense, but I can't find this question already answered, nor can I find an answer in the voluminous help, or if it is there, I'm not recognizing it.

I'm writing a book. Each chapter is in its own folder, and I go through lots of small revisions. *** I write and edit, save, close, go into File Manager (before I found XY!), ctrl-c, ctrl-v, and let FM make its default name. Then I reopen the main file and repeat from ***. Some chapters have slightly different versions with a unique base name, so my folders all have bazillions of files like

ReversingShapingComputer.odt
ReversingShapingComputer - Copy.odt
ReversingShapingComputer - Copy (2).odt
ReversingShapingComputer - Copy (3).odt
ReversingShapingComputer - Copy (4).odt
ReversingShapingPaper.odt
ReversingShapingPaper - Copy.odt
ReversingShapingPaper - Copy (2).odt
ReversingShapingPaper - Copy (3).odt
ReversingShapingPaper - Copy (4).odt

I've figured out how to add the modified date in my preferred format to these filenames, using Batch Rename with the string

* <datem -yyyymmdd-hhmmss>

Woo-hoo!

I'd like to delete all the stupidly designed default copy strings, from the initial space to the closing parenthesis. In *nix systems, I could send

s/ .*)//

to sed, so I tried

' .*)' > ''

but the regexp is not valid in XY, and switching single to double quotes doesn’t work either. What am I doing wrong? And naturally, deleting the ' .*)' and appending the modified date at the same time would be great. :-)

(I could not find the list of regexp tokens, even in the massive PDF. Again, my apologies for being dense.)

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Renaming default Windows File Manager copies

Post by highend »

Welcome to the forum

Code: Select all

)
is still a meta character and needs to be escaped

In other words, the pattern for the regexreplace is:

Code: Select all

# .*\) > #
Remove # from it, they were just used to show that there is a leading and a trailing space!

But be careful with such a pattern, it's greedy!

Better make it more specific like:

Code: Select all

# - copy \(\d+\) > #
and appending the modified date at the same time would be great. :-)
Only possible via scripting (in one go)...
One of my scripts helped you out? Please donate via Paypal

ilexedits
Posts: 8
Joined: 19 Aug 2017 18:04

Re: Renaming default Windows File Manager copies

Post by ilexedits »

Just to close the loop (mainly for others who are trying to do the same thing),
1. select the files
2. File | Batch Rename
3. put the following string in the box to append the file's modified date, indicated by the "m" in "datem" (adding or removing date components, time components, hyphens, underscores, etc.):

*-<datem yyyymmdd-hhmmss>

4. click preview, then OK
5. make sure same files are still selected
6. File | RegExp Rename
7. put the following string in the box changing each underscore to a space to remove copy numbers like "Copy (2)" as well as the first copy's " - Copy":

_-_Copy_\(\d+\)_>_

_-_Copy(_\(\d+\))?_>_

Thanks!
Last edited by ilexedits on 21 Aug 2017 16:59, edited 1 time in total.

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Renaming default Windows File Manager copies

Post by highend »

as well as the first copy's " - Copy":
No, your requirement was:
from the initial space to the closing parenthesis
And the regex doesn't remove

Code: Select all

_-_Copy
without
parenthesis (+ the number) afterwards...

You'd need e.g. this to do this as well:

Code: Select all

_-_Copy(_\(\d+\))?_>_
One of my scripts helped you out? Please donate via Paypal

ilexedits
Posts: 8
Joined: 19 Aug 2017 18:04

Re: Renaming default Windows File Manager copies

Post by ilexedits »

Highend, thanks so much for catching this.

(I did some more poking, but I still can't find the regexp list of tokens, what needs escaping, etc.)

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Renaming default Windows File Manager copies

Post by highend »

It's the Visual Basic 6.0 regex engine. Google should deliver all its details
One of my scripts helped you out? Please donate via Paypal

ilexedits
Posts: 8
Joined: 19 Aug 2017 18:04

Re: Renaming default Windows File Manager copies

Post by ilexedits »

Marvy, thanks!

Post Reply