[GH-ISSUE #76] New custom command option: remove file extension #75

Closed
opened 2026-02-25 21:32:35 +03:00 by kerem · 15 comments
Owner

Originally created by @Jack1789 on GitHub (Aug 25, 2019).
Original GitHub issue: https://github.com/clechasseur/pathcopycopy/issues/76

Originally assigned to: @clechasseur on GitHub.

Hi, it would be useful if an extra base command could be added to your program, one which drops the extensions. So, something like this:

"PATHCO~1.EXE"
"PathCopyCopySettings.exe"

Turns into something like this:

"PATHCO~1"
"PathCopyCopySettings"

I'm currently using a customized command, which implements an additional regex expression to reach the desired result:

^(.*)\.[^.]*$
$1

But I would like to further customize it, so it replaces every dot it finds with spaces, like this:

"PathCopyCopySettings.2019.test.exe"

"PathCopyCopySettings 2019 test"

I don't know how to get the right regex for that, but if there were an extra base command which already drops the filenames' extension, I could simply use the "find / replace" option to modify it.

Thanks.

Edit: Fixed the "...one which don't drops..." typo.
Edit 2: Fixed the regex expression since the site wasn't displaying it correctly.

Originally created by @Jack1789 on GitHub (Aug 25, 2019). Original GitHub issue: https://github.com/clechasseur/pathcopycopy/issues/76 Originally assigned to: @clechasseur on GitHub. Hi, it would be useful if an extra base command could be added to your program, one which drops the extensions. So, something like this: "**PATHCO~1.EXE**" "**PathCopyCopySettings.exe**" Turns into something like this: "**PATHCO~1**" "**PathCopyCopySettings**" I'm currently using a customized command, which implements an additional regex expression to reach the desired result: ``` ^(.*)\.[^.]*$ $1 ``` But I would like to further customize it, so it replaces every dot it finds with spaces, like this: "**PathCopyCopySettings.2019.test.exe**" "**PathCopyCopySettings 2019 test**" I don't know how to get the right regex for that, but if there were an extra base command which already drops the filenames' extension, I could simply use the "find / replace" option to modify it. Thanks. **Edit:** Fixed the "...one which **don't** drops..." typo. **Edit 2:** Fixed the regex expression since the site wasn't displaying it correctly.
kerem 2026-02-25 21:32:35 +03:00
Author
Owner

@clechasseur commented on GitHub (Aug 25, 2019):

I don't think a new base command would work because it would essentially mean duplicating something - but a new custom command option makes sense.

<!-- gh-comment-id:524662417 --> @clechasseur commented on GitHub (Aug 25, 2019): I don't think a new base command would work because it would essentially mean duplicating something - but a new custom command option makes sense.
Author
Owner

@blackcrack commented on GitHub (Aug 25, 2019):

if, then let copy the name like it is, with points and the user can remove the points, because, then stay's original.. "copy the name, without extension"
This let you stay on the way.. if it's take the "originnal.file.name" .ext
or if the name "the orginal file name.ext" so "the orginal file name"

best regards
blacky

edit:
btw:

 set var=D:\Name.txt
 FOR %%i IN ("%var%") DO (
    ECHO Drive=%%~di
    ECHO Path=%%~pi
    ECHO Name=%%~ni
    ECHO extension=%%~xi
)

but don't forget sambapath's //network/path

<!-- gh-comment-id:524670639 --> @blackcrack commented on GitHub (Aug 25, 2019): if, then let copy the name like it is, with points and the user can remove the points, because, then stay's original.. "copy the name, without extension" This let you stay on the way.. if it's take the "originnal.file.name" .ext or if the name "the orginal file name.ext" so "the orginal file name" best regards blacky edit: btw: ``` set var=D:\Name.txt FOR %%i IN ("%var%") DO ( ECHO Drive=%%~di ECHO Path=%%~pi ECHO Name=%%~ni ECHO extension=%%~xi ) ``` but don't forget sambapath's //network/path
Author
Owner

@clechasseur commented on GitHub (Aug 25, 2019):

Thanks for the tips. I won't spawn a command prompt just to extract path without extension however, since it can be done via regex already. And I will take care of supporting forward slashes in paths, yes. 😀

<!-- gh-comment-id:524673763 --> @clechasseur commented on GitHub (Aug 25, 2019): Thanks for the tips. I won't spawn a command prompt just to extract path without extension however, since it can be done via regex already. And I will take care of supporting forward slashes in paths, yes. 😀
Author
Owner

@clechasseur commented on GitHub (Aug 25, 2019):

Implemented in next version (17.0).

<!-- gh-comment-id:524674002 --> @clechasseur commented on GitHub (Aug 25, 2019): Implemented in next version (17.0).
Author
Owner

@blackcrack commented on GitHub (Aug 26, 2019):

@clechasseur
i be at moment playing around to make a win7 update dvd,
if you whant a look : http://www.blackysgate.de/files/folder-root/batch-files/

<!-- gh-comment-id:524687419 --> @blackcrack commented on GitHub (Aug 26, 2019): @clechasseur i be at moment playing around to make a win7 update dvd, if you whant a look : http://www.blackysgate.de/files/folder-root/batch-files/
Author
Owner

@Jack1789 commented on GitHub (Aug 26, 2019):

Hi, I didn't get the "duplicating something" part of your answer, since as far as I know, there is no base commands that do that already present. By the way, would you please tell me what to add to the next regex expression, so it replaces dots with spaces:

^(.*)\.[^.]*$
$1

So I can just add a new custom command.

Thanks.

<!-- gh-comment-id:524771566 --> @Jack1789 commented on GitHub (Aug 26, 2019): Hi, I didn't get the "duplicating something" part of your answer, since as far as I know, there is no base commands that do that already present. By the way, would you please tell me what to add to the next regex expression, so it replaces dots with spaces: ``` ^(.*)\.[^.]*$ $1 ``` So I can just add a new custom command. Thanks.
Author
Owner

@clechasseur commented on GitHub (Aug 26, 2019):

Replacing dots with spaces wouldn't even require a regular expression, I think. Simply perform a find for . and replace with .

<!-- gh-comment-id:524901907 --> @clechasseur commented on GitHub (Aug 26, 2019): Replacing dots with spaces wouldn't even require a regular expression, I think. Simply perform a find for `.` and replace with ` `.
Author
Owner

@blackcrack commented on GitHub (Aug 26, 2019):

hmm.. and if the user want the point in the name ?
i have a couples file who have a point vor versioning.. filesx.3.2.5.zip

this removing of the points should be optional... in any case ...

best regards
Blacky

<!-- gh-comment-id:524913903 --> @blackcrack commented on GitHub (Aug 26, 2019): hmm.. and if the user want the point in the name ? i have a couples file who have a point vor versioning.. filesx.3.2.5.zip this removing of the points should be optional... in any case ... best regards Blacky
Author
Owner

@clechasseur commented on GitHub (Aug 26, 2019):

@blackcrack Not sure what you mean - I was answering @Jack1789 , so the comments about replacing dots were for his own personal use - they are not part of the Path Copy Copy product.

As for the new option, it will only remove the last dot which is part of the file extension. In your example, you would end up with filesx.3.2.5.

<!-- gh-comment-id:524956609 --> @clechasseur commented on GitHub (Aug 26, 2019): @blackcrack Not sure what you mean - I was answering @Jack1789 , so the comments about replacing dots were for his own personal use - they are not part of the Path Copy Copy product. As for the new option, it will only remove the last dot which is part of the file extension. In your example, you would end up with `filesx.3.2.5`.
Author
Owner

@blackcrack commented on GitHub (Aug 26, 2019):

oh for personal use.. had not seen th whole posts.. my fault..
sorry :)
the last dot is clear,, infront of the extension ..

best :)

<!-- gh-comment-id:525073063 --> @blackcrack commented on GitHub (Aug 26, 2019): oh for personal use.. had not seen th whole posts.. my fault.. sorry :) the last dot is clear,, infront of the extension .. best :)
Author
Owner

@Jack1789 commented on GitHub (Aug 26, 2019):

Replacing dots with spaces wouldn't even require a regular expression, I think. Simply perform a find for . and replace with .

The thing is, I'm already "occupying" the find/replace option with that regex I mentioned before, which drops extensions from filenames. So, I'm wondering how to further tweak that regex expression, so it also do the dots per spaces replacing.

<!-- gh-comment-id:525073739 --> @Jack1789 commented on GitHub (Aug 26, 2019): > > > Replacing dots with spaces wouldn't even require a regular expression, I think. Simply perform a find for `.` and replace with ` `. The thing is, I'm already "occupying" the find/replace option with that regex I mentioned before, which drops extensions from filenames. So, I'm wondering how to further tweak that regex expression, so it also do the dots per spaces replacing.
Author
Owner

@clechasseur commented on GitHub (Aug 27, 2019):

The thing is, I'm already "occupying" the find/replace option with that regex I mentioned before, which drops extensions from filenames. So, I'm wondering how to further tweak that regex expression, so it also do the dots per spaces replacing.

Unfortunately, I'm not sure it's possible to do both in a single regular expression. You have two solutions:

  • Wait for the release of version 17.0, which will add the option to remove extension without using the regular expression, or
  • Craft a custom command that uses two regular expressions.

That last one is possible because under the hood, custom commands use a pipeline of elements that modify the path, and it's possible to have an arbitrary number of elements in any order. The Settings application does not let you do this, but you can craft it manually.

If you want some help, export your custom command and attach the .ecc file here, I'll try to show you how to craft a custom command doing what you want.

<!-- gh-comment-id:525127876 --> @clechasseur commented on GitHub (Aug 27, 2019): > The thing is, I'm already "occupying" the find/replace option with that regex I mentioned before, which drops extensions from filenames. So, I'm wondering how to further tweak that regex expression, so it also do the dots per spaces replacing. Unfortunately, I'm not sure it's possible to do both in a single regular expression. You have two solutions: - Wait for the release of version 17.0, which will add the option to remove extension without using the regular expression, or - Craft a custom command that uses two regular expressions. That last one is possible because under the hood, custom commands use a *pipeline* of elements that modify the path, and it's possible to have an arbitrary number of elements in any order. The Settings application does not let you do this, but you can craft it manually. If you want some help, export your custom command and attach the `.ecc` file here, I'll try to show you how to craft a custom command doing what you want.
Author
Owner

@Jack1789 commented on GitHub (Aug 27, 2019):

OK, I bet in the next v17 version I will just use the new command which drops extension, and use the "find/replace" option to replace dot per spaces, but meanwhile, here I leave you the .ecc file:

Filename.Without.Extension.zip

If there was the chance of combining multiple "find/replace" wildcards commands into the respective fields, I would simply use one for the extension's deletion, and another one for the dots replacing (maybe comma separated values); moreover, that would let me skip having to deal with regular expressions, which is painfully difficult to learn, at least to me.

Thanks.

<!-- gh-comment-id:525208575 --> @Jack1789 commented on GitHub (Aug 27, 2019): OK, I bet in the next v17 version I will just use the new command which drops extension, and use the "find/replace" option to replace dot per spaces, but meanwhile, here I leave you the .ecc file: [Filename.Without.Extension.zip](https://github.com/clechasseur/pathcopycopy/files/3545156/Filename.Without.Extension.zip) If there was the chance of combining multiple "find/replace" wildcards commands into the respective fields, I would simply use one for the extension's deletion, and another one for the dots replacing (maybe comma separated values); moreover, that would let me skip having to deal with regular expressions, which is painfully difficult to learn, at least to me. Thanks.
Author
Owner

@clechasseur commented on GitHub (Sep 1, 2019):

@Jack1789 Try this:

Filename.Without.Extension.Or.Dots.zip

It should work as you want. Note however that you will no longer be able to edit the custom command using the Settings application; doing so will break the new find/replace element.

<!-- gh-comment-id:526874443 --> @clechasseur commented on GitHub (Sep 1, 2019): @Jack1789 Try this: [Filename.Without.Extension.Or.Dots.zip](https://github.com/clechasseur/pathcopycopy/files/3562954/Filename.Without.Extension.Or.Dots.zip) It should work as you want. Note however that you will no longer be able to edit the custom command using the Settings application; doing so will break the new find/replace element.
Author
Owner

@Jack1789 commented on GitHub (Sep 1, 2019):

It works fine, thanks.

<!-- gh-comment-id:526917175 --> @Jack1789 commented on GitHub (Sep 1, 2019): It works fine, thanks.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/pathcopycopy#75
No description provided.