Page 1 of 1
Como sacar los números?
Posted: 27 Aug 2023 16:05
by macoga
Hola a todos, estuve alejado un tiempo por salud. ahora buscando un codigo CMD para eliminar numeros de una lista de texto desde el 1 al 999, por ejemplo: 1-amigos, 99-familia, 300-direcciones. Que solo queden las palabras.
Gracias de antemano y un saludo a todos
Re: Como sacar los números?
Posted: 27 Aug 2023 19:22
by Aacini
Lo primero que debes saber es que éste es un sitio en inglés. Debes traducir tus preguntas usando cualquier traductor (por ejemplo, pon en la barra de Google: "significado de english en español").
Las preguntas deben ser claras. Aunque tu pregunta es lo bastante sencilla para entenderla, deberías poner un ejemplo de los archivos de entrada y salida que deseas.
Este archivo Batch hace lo que pides:
Code: Select all
@echo off
(for /F "tokens=1* delims=-" %%a in (entrada.txt) do echo %%b) > salida.txt
También puedes teclear directamente ese comando en la línea de comandos de esta manera:
Code: Select all
(for /F "tokens=1* delims=-" %a in (entrada.txt) do @echo %b) > salida.txt
Lo que sigue es la traducción al inglés de mi respuesta que obtuve de la manera que dije antes.
-------------------------------------------------------------
The first thing you should know is that this is an English site. You must translate your questions using any translator (for example, put in the Google toolbar: "english meaning in spanish").
The questions must be clear. Although your question is simple enough to understand, you should give an example of the input and output files you want.
This Batch file does what you ask:
What follows is the English translation of my answer that I got the way I said before.
Antonio
Re: Como sacar los números?
Posted: 28 Aug 2023 08:13
by macoga
Hello everyone, I was away for a while for health reasons. I am now looking for a CMD code to remove numbers from a text list that I have in a folder.
The list have a bunch of txt files from 1 to 999,
for example:
1-friends
20-recipes
99-family
300-addresses
So, I need to take the number and the dash off to end up like this:
friends
recipes
family
addresses
Thanks Aacini, for the translation tip, and cmd code, I was trying a vbs code and didn´t work.
Re: Take Numbers off a list?
Posted: 28 Aug 2023 08:33
by macoga
I guess didn´t explain my first question right, Aacini. Sorry!!!!
I did the translation as you show me,thanks.
I have a folder with hundreds of txt files, and they are number as I said before, I need a code where I can put the path to that folder, then take the numbers off.
I really thanks you Aacini
Re: Como sacar los números?
Posted: 28 Aug 2023 08:47
by Batcher
test.bat
Code: Select all
@echo off
cd /d "%~dp0"
for /f "tokens=1* delims=-" %%i in ('dir /b /a-d *.txt ^| findstr /b "[0-9][0-9]*-"') do (
ren "%%i-%%j" "%%j"
)
Re: Como sacar los números?
Posted: 29 Aug 2023 18:36
by Aacini
macoga wrote: ↑28 Aug 2023 08:13
Hello everyone, I was away for a while for health reasons. I am now looking for a CMD code to remove numbers from a text list that I have in a folder.
The list have a bunch of txt files from 1 to 999,
for example:
1-friends
20-recipes
99-family
300-addresses
So, I need to take the number and the dash off to end up like this:
friends
recipes
family
addresses
Thanks Aacini, for the translation tip, and cmd code, I was trying a vbs code and didn´t work.
Hey! You
altered your original question when you translated it!
This is your original question, translated to English:
Hello everyone, I was away for a while for health. now looking for a CMD code to remove numbers from a text list from 1 to 999, for example: 1-friends, 99-family, 300-addresses. Let only the words remain.
In your altered question you added "
in a folder" and "The list have a bunch of txt
files". In this
new question it is obvious that you have
several files, but in your original question you suggested that you have "a text list", in
one file!
Re: Como sacar los números?
Posted: 31 Aug 2023 18:45
by macoga
You are right Aacini, and my apologies, but when I translated it I thought more about the question, and yes the text files are inside a folder, so the code needs a path to it, and then a command to get rid off the left digits up to the dash (-)
Re: Como sacar los números?
Posted: 31 Aug 2023 18:50
by macoga
The same apologies to Batcher, as he also send a code just for a list.
Re: Como sacar los números?
Posted: 31 Aug 2023 21:20
by Batcher
test-2.bat
Code: Select all
@echo off
cd /d "path/to/your/folder"
for /f "tokens=1* delims=-" %%i in ('dir /b /a-d *.txt ^| findstr /b "[0-9][0-9]*-"') do (
ren "%%i-%%j" "%%j"
)
Re: Como sacar los números?
Posted: 30 Sep 2023 16:31
by macoga
Beautifully done, thanks Batcher, works great
I should change the title of the request to English