简体   繁体   English

我想使用批处理脚本/cmd 从目录中的每个 txt 文件中删除最后一个字符

[英]I want to remove last character from each txt file in a directory using batch script/cmd

I have some .txt files for example:例如,我有一些.txt文件:

a.txt
b.txt

Each line of these files contain numbers in the below format:这些文件的每一行都包含以下格式的数字:

9999999999,  
1111111111,

I want to remove , after each number by way of a batch script.我想通过批处理脚本在每个数字之后删除,

The result should be like:结果应该是这样的:

9999999999
1111111111
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION 
FOR %%e IN (u:\a.txt u:\b.txt "u:\your files\c one.txt") DO (
 >u:\dummy.tmp (
 FOR /f %%y IN ('TYPE %%e') DO (
  SET "line=%%y"
  ECHO !line:~0,-1!
 )
 )
 MOVE /y u:\dummy.tmp %%e >nul
)

GOTO :EOF

Always verify against a test directory before applying to real data.在应用于真实数据之前,请始终对照测试目录进行验证。

Filenames are my test files.文件名是我的测试文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用批处理脚本从文件中删除第一个和最后一个字符? - How to remove the first and last character from a file using batch script? 如何使用cmd附加到.txt文件的每一行 - How do I append to each line of a .txt file using cmd 使用批处理脚本 from.txt 文件在每 2 行之后需要一个空格 - Need a space blank after each of 2 lines using batch script from .txt file 从Windows批处理文件中的字符串中删除第一个和最后一个字符 - Remove first and last character from a String in a Windows Batch file CMD 批处理文件循环遍历目录并将文件路径写入 TXT - CMD batch file to Loop over Directory and Write File Paths to TXT CMD批处理-在循环浏览文件时搜索字符的最后一次出现 - CMD Batch - Search for last occurence of character while looping through file 如何通过批处理脚本从TXT文件的最后一行提取最后一个单词 - How to extract the last word from the last line of a TXT file through a batch script 使用cmd(脚本)对txt文件的行和字符x进行更改 - make change on line and character x of txt file with cmd ( script) 使用cmd文件从PATH中删除不需要的目录 - Remove unwanted directory from PATH using cmd file 使用批处理脚本解析文本文件并从每行中删除前 2 个字符 - Parse a text file using batch script and remove the first 2 characters from each line
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM