0
Hello. I am looking forward to facing a situation at Windows 10 CMD command prompt of "dynamic name", so to speak.
SITUATION EXAMPLE:
I have in my directory the following file:
.../DADOS/teste.csv
(whereas of all the files in that directory, this is the only one with the extension .csv)
My intention is to create any new file, but with this same name in any other directory. However, I need you to accomplish this task by using cmd commands so I can put it in a beginner script.
My initial solution was the following:
First I needed to copy the file name. I’m sure there must be an easier command to copy the file name. But I did it through the sequence of commands:
(1)
.../DADOS>dir /b *csv > nome.txt
. This command creates a txt file with the name of the file I want ('test.csv').
this can be viewed with the command
...DADOS>type nome.txt
that will display test.csv (the only line written in the file 'name.txt')
(2) I copied the text written in the pro file (clipboard) with the CLIP command:
.../DADOS>clip < nome.txt
Here, if I hit CTRL+V or (for paste option) in any editor I can prove that I copied the text 'name.txt'.
Ready! I have the text I want in the clipboard.
Now what I need is; if I create any file in another directory, for example...
.../dados2>echo > novo_arquivo.txt
my goal is to rename this new file with the text in "Clipboard" using a cmd command line, do not use CTRL+V or mouse button.
I need this
.../dados2/novo_arquivo.txt
--rename--> .../dados2/teste.csv
would be something like
>rename nome_original novo_nome=clipboard
or
>rename novo_arquivo.txt novo_nome_clipboard
(but I need a command that actually worked on the windows cmd).
NOTE: Notice that I used the term "dynamic name" at the beginning, because in this case, the name of the new file would always be changing, according to the name of the initial file. I thought it would be simple to create a sequence of commands that copies the name of the first file and in front, when I needed, use this name (that would be in the Clipboard) to rename a new file.
Can someone help me? How to create a file and rename it with the text of the clipboard, or already create a file with the name copied in the Clipboard. Or you can make that nomenclature reference.