Como sacar los números?
Moderator: DosItHelp
Como sacar los números?
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
Gracias de antemano y un saludo a todos
Re: Como sacar los números?
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:
También puedes teclear directamente ese comando en la línea de comandos de esta manera:
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
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
Code: Select all
(for /F "tokens=1* delims=-" %a in (entrada.txt) do @echo %b) > salida.txt
-------------------------------------------------------------
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:
Code: Select all
. . .
Antonio
Re: Como sacar los números?
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.
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?
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
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?
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?
Hey! You altered your original question when you translated it!macoga wrote: ↑28 Aug 2023 08:13Hello 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.
This is your original question, translated to English:
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!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.
Re: Como sacar los números?
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?
The same apologies to Batcher, as he also send a code just for a list.
Re: Como sacar los números?
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?
Beautifully done, thanks Batcher, works great
I should change the title of the request to English
I should change the title of the request to English