Copy name

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Eureka!
Posts: 136
Joined: 25 Jul 2019 18:25

Re: Copy name

#16 Post by Eureka! » 07 Feb 2020 07:00

No problem!
celsius wrote:
06 Feb 2020 22:42
The last button I'd like to create is one that selects all files with the same extension of the already selected file. Do you think is possible through the command line?
Does this come close?
( I already removed everything OpenShell related, so can't test )

Code: Select all

%SystemRoot%\System32\cmd.exe  /c @for %%x in ("%2") do @dir /b "%%~dpx*%%~xx"|clip

celsius
Posts: 11
Joined: 05 Feb 2020 01:27

Re: Copy name

#17 Post by celsius » 07 Feb 2020 08:43

Thanks,
With your script the filename with extension is copied to clipboard.
I didn't explain myself well, sorry. What I mean is the selection in Windows Explorer of all files with the same extension of the already selected file. (Just to be more precise: if you hit "CTRL + a" you select all files in Explorer. Well, I'd like instead a selection by extension)

Eureka!
Posts: 136
Joined: 25 Jul 2019 18:25

Re: Copy name

#18 Post by Eureka! » 07 Feb 2020 10:59

This is how I understood things:
  • In Explorer, you are in folder C:\test
  • In C:\test are the following files:
    - abc.txt
    - abc.pdf
    - def.txt
    - def.mp3
    - ghi.txt
    - ghi.jpg
  • You select def.txt
  • You press the "magic button"
  • Clipboard contains:
    abc.txt
    def.txt
    ghi.txt
That is what I wrote (/intended to write :s)

What happens with this command? Please paste the content of the CMD window.

Code: Select all

%SystemRoot%\System32\cmd.exe  /k @for %%x in ("%2") do @dir /b "%%~dpx*%%~xx"

celsius
Posts: 11
Joined: 05 Feb 2020 01:27

Re: Copy name

#19 Post by celsius » 07 Feb 2020 11:38

Yes, all files with the same extension are copied to clipboard and it is very interesting
This is an output example:

4kvideodownloader_4.10.1_x64.zip
4kvideodownloader_4.9.0_x64.zip
4kvideodownloader_4.9.3_x64.zip
dsynchronize.zip
Everything-1.4.1.935.x64.zip
movienizer_portable(1).zip
NConvert-win64.zip
peazip_portable-6.8.1.WIN64.zip
pestudio.zip
sumo.zip
TakeOwnershipEx.zip
tportable.1.9.3.zip
tportable.1.9.7.zip
UWT4.zip
winaerotweaker(2).zip
winmerge-2.16.2-x64-exe.zip
XnConvert-win-x64.zip
XnViewMP-win-x64.zip


However, that is not what I'd like to obtain.
I don't want to copy their filenames, I'd like to have a Windows Explorer selection of these files, so I can copy, cut or delete them

Eureka!
Posts: 136
Joined: 25 Jul 2019 18:25

Re: Copy name

#20 Post by Eureka! » 07 Feb 2020 12:24

celsius wrote:
07 Feb 2020 11:38
I'd like to have a Windows Explorer selection of these files
Not possible this way.

Alternatives:
- AutoHotKey/AutoIt script
- In Explorer, group files by File Extension and click the .zip header. All .zip files are selected.

penpen
Expert
Posts: 1991
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Copy name

#21 Post by penpen » 07 Feb 2020 13:31

You could write a little C++ or C# program, see examples here:
- C++ https://stackoverflow.com/a/3011284 and
- C# https://stackoverflow.com/a/3578581.

Depending on the needed used version the C# sample might been compilable using batch, see:
viewtopic.php?t=5260.

penpen

Eureka!
Posts: 136
Joined: 25 Jul 2019 18:25

Re: Copy name

#22 Post by Eureka! » 07 Feb 2020 14:19

.. or use a file manager like Total Commander (or one of it's gazillion clones).
With keyboard shortcut ALT+Numeric+ or Menu:Mark > Select All With Same Extension you select all files with the same extension.

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: Copy name

#23 Post by Squashman » 07 Feb 2020 18:26

celsius wrote:
07 Feb 2020 11:38
I don't want to copy their filenames, I'd like to have a Windows Explorer selection of these files, so I can copy, cut or delete them
How was anybody on this planet supposed to ascertain that from your original post.
celsius wrote:
05 Feb 2020 01:41
Hi, Greetings to all users of this forum

I need help to modify this command

Code: Select all

cmd /c echo|set /p="%2"|clip
It copies full path of the selected file, I'd like instead coping only the name without extension
I know this is an elementary request, I'm sorry but, please, be patient

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Copy name

#24 Post by ShadowThief » 08 Feb 2020 04:16

Squashman wrote:
07 Feb 2020 18:26
celsius wrote:
07 Feb 2020 11:38
I don't want to copy their filenames, I'd like to have a Windows Explorer selection of these files, so I can copy, cut or delete them
How was anybody on this planet supposed to ascertain that from your original post.
celsius wrote:
05 Feb 2020 01:41
Hi, Greetings to all users of this forum

I need help to modify this command

Code: Select all

cmd /c echo|set /p="%2"|clip
It copies full path of the selected file, I'd like instead coping only the name without extension
I know this is an elementary request, I'm sorry but, please, be patient
They didn't come up with that until the last post on the first page

Eureka!
Posts: 136
Joined: 25 Jul 2019 18:25

Re: Copy name

#25 Post by Eureka! » 08 Feb 2020 06:00

ShadowThief wrote:
08 Feb 2020 04:16
@celcius didn't come up with that until the last post on the first page
Fixed that for you :)

But he is indeed very sloppy in describing what he wants/what the results are/what the situation is/...
I regret spending my time on this.

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Copy name

#26 Post by ShadowThief » 08 Feb 2020 07:59

Yes, "celsius" was the antecedent to which "they" was referring. :)

But yeah, classic newbie technique of going "hey, I have another question about the same project I'm working on; it's a totally different feature, but I'm already getting help in this topic so I'll just keep asking here because people are still looking, right?" It kind of makes sense. A lot of the time people will create new topics about expanding features that were created in previous topics and everybody says "geez, stick to a single topic." When you're looking too closely at a project, it can be hard to see the separate parts instead of the whole thing so the line that tells you where to make separate topics can be blurry.

celsius
Posts: 11
Joined: 05 Feb 2020 01:27

Re: Copy name

#27 Post by celsius » 08 Feb 2020 08:10

Sorry for the delay,
How was anybody on this planet supposed to ascertain that from your original post.
This is a second request, since @Eureka! helps me to solve my primary issue that was
celsius wrote:
05 Feb 2020 01:41
I need help to modify this command

Code: Select all

cmd /c echo|set /p="%2"|clip
It copies full path of the selected file, I'd like instead coping only the name without extension
I asked for a second and my last request. Select all files by extension in Explorer is the last button I'd like to have in my toolbar



Eureka! wrote:
08 Feb 2020 06:00
But he is indeed very sloppy in describing what he wants/what the results are/what the situation is/...
Sorry if I'm not explain my request very well, I'm not very familiar with english
Eureka! wrote:
08 Feb 2020 06:00
I regret spending my time on this.
I'm very sorry about this


Apologize with all forum user and thanks for your support

Eureka!
Posts: 136
Joined: 25 Jul 2019 18:25

Re: Copy name

#28 Post by Eureka! » 08 Feb 2020 17:20

celsius wrote:
08 Feb 2020 08:10
Sorry if I'm not explain my request very well, I'm not very familiar with english
Your English is not the problem (as far as I can tell; English is not my native language either).

Let me try to explain:
When someone asks a question, for all readers everything is "dark"; we can't see your screen, we don't know your situation, All we know is what you tell us.

When you post feedback like "it doesn't work", it stays dark at the other end of the line.
And when you say " I tried 0 4 5 without luck", nobody will understand what you mean until you tell them. I had to install OpenShell to find out what you meant.
For clarity, compare it with a little child on the phone. He/she will start pointing at things saying "there". The other side of the line of course has no idea what and where "there" is.

After years of helping people on various forums I have learned to ignore these people as it leads to frustration ("help me build a house" followed by "O sorry, I meant a car").
( Other people might have less problems with that, but I do.)

And that is not entirely your fault, as it is extremely difficult to think -and think again- about how to formulate your question. Especially if it not someone's area of expertise.
If everyone knew what to ask and what information to provide, these suggestions would not be needed.

Long story short: this wasn't primarily directed at you, but at myself.

Post Reply