当前位置:首页 » 网页前端 » txt脚本重命名
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

txt脚本重命名

发布时间: 2022-09-25 15:49:22

❶ 怎样给500个txt文件重新命名

1)用程序一次性读取肯定会内存溢出的。
2)可以在linux下,用指令去实现
将file1.txt和file2.txt合并到file.txt
cat file1.txt file2.txt > file.txt
或者
将file1.txt追加到file2.txt的末尾
$ cat file1.txt >> file2.txt
3)可以用shell写脚本分割文件,最终把所有小文件,往一个空文件里追加

❷ 批处理能实现从txt文件中提取文件名并重命名目录下文件吗

不清楚你的实际文件/情况,仅以问题中的说明及猜测为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI,跟要处理的文件放一起双击运行
<# :
cls
@echo off
rem 将当前文件夹里的文件依据一个指定txt文本文件里列出的新文件名按顺序重命名
mode con lines=3000
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
cd /d "%~dp0"
powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::GetEncoding('GB2312')))) -Args '%~f0'"
echo;%#% +%$%%$%/%@% %z%
pause
exit
#>
$txtfile="文件名列表.txt";

$self=get-item -liter $args[0];
$path=$self.Directory.FullName;

if(-not (test-path -liter $txtfile)){write-host ('"'+$txtfile+'" not found');exit;};
$text=[IO.File]::ReadAllLines($txtfile,[Text.Encoding]::GetEncoding('GB2312'));

$codes=@'
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public static class ExpDir
{
[DllImport("Shlwapi.dll", CharSet=CharSet.Unicode)]
public static extern int StrCmpLogicalW(string p1, string p2);
public static string[] Sort(string[] f)
{
Array.Sort(f, StrCmpLogicalW);
return f;
}
}
'@;
Add-Type -TypeDefinition $codes;

[byte[]]$b=@(32,45,45,62,32);
$c=[Text.Encoding]::Default.GetString($b);
$files=@(dir -liter $path|?{($_.Name -ne $txtfile) -and ($_.Name -ne $self.Name) -and ($_ -is [System.IO.FileInfo])}|%{$_.Name});
$arr=[ExpDir]::Sort($files);
for($i=0;$i -lt $arr.Count;$i++){
if($i -lt $text.Count){$arr[$i]+$c+$text[$i];}
}

❸ 怎样批量重命名一个文件夹下的文件名

批量将文件名修改为001.txt,002.txt,003.txt,004.txt,......

步骤1,在电脑上下载批量重命名软件后安装打开,如下图所示点击任意一个红框位置,将需要重命名的文件全部导入到软件中,如果导入的文件比较多请等待一小会。

❹ 我在用TXT文本文档的时候想重命名,却出现了这种情况,请问该如何解决

答:询问而已,没事。如果你本来的扩展名就是TXT,点是。
解释:譬如你本来文件的扩展是.exe你重命名扩展名为.txT.会出现这个对话框,因为扩展名是告诉系统程序这文件该以怎样的方式运行。exe与txt的运行方式是不同,改变扩展名后会导致文件不能运行。

❺ 求txt文件批量重命名的软件(截取文件内容文字做文件名)

这种重命名的要求有点过分,推荐用软件Replace Pioneer,可以使用一些技巧随机选取文字,详细步骤:

1. 打开Tools->Batch Runner菜单
2. 把待处理的txt文件从windows文件浏览器拖拽到Batch Runner窗口中
3. 选中Set output filename选项,并把后面的${FILENAME}改为:
###_${FILENAME}<file_content($match,'.{'.int(rand(100)).'}(.{10})','',100,'nametext')>.${EXT}
4. 观察output file一列的新文件名是否满足要求,然后点击File Rename即可。

以上公式会从文件前100个字里,随机选取连续的10个字做文件名。
比如,新文件名可能是:001_随机选取部分文字做文.txt。

如果不是随机取,只是想取文件前10个字,第3步就简单些:
###_${FIRSTLINE}{1,10}.${EXT}

更多重命名的例子和公式,可以参考Replace Pioneer网络里的文件重命名部分。

❻ 求批处理按txt列表重命名文件bat代码

不清楚你的实际文件/情况,仅以问题中的样例/说明为据;以下代码复制粘贴到记事本,另存为xx.bat;txt和bat需存为ANSI/GB2312编码,跟要处理的多个文件放一起双击运行
<# :
cls&echo off&mode con lines=5000
rem 根据一个txt文本文件内列出的多个新名称列表,将当前文件夹里的多个文件一一对应重命名
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
cd /d "%~dp0"
set "txtfile=.\list.txt"
if not exist "%txtfile%" (echo;"%txtfile%" 未找到&pause&exit)
powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::GetEncoding('GB2312')))) -Args '%~f0'"
echo;%#% +%$%%$%/%@% %z%
pause
exit
#>
$codes=@'
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public static class ExpDir
{
[DllImport("Shlwapi.dll", CharSet=CharSet.Unicode)]
public static extern int StrCmpLogicalW(string p1, string p2);
public static string[] Sort(string[] f)
{
Array.Sort(f, StrCmpLogicalW);
return f;
}
}
'@;
Add-Type -TypeDefinition $codes;

[byte[]]$b=@(32,45,45,62,32);
$c=[Text.Encoding]::Default.GetString($b);
$self=get-item -liter $args[0];
$path=$self.Directory.FullName;
$txtfile=get-item -liter $env:txtfile;
$text=[IO.File]::ReadAllLines($txtfile.FullName,[Text.Encoding]::GetEncoding('GB2312'));
$arr=@(dir -liter $path|?{($self.Name -ne $_.Name) -and ($txtfile.Name -ne $_.Name) -and ($_ -is [System.IO.FileInfo])}|%{$_.Name});
if($arr.length -ge 1){
$files=[ExpDir]::Sort($arr);
for($i=0;$i -lt $files.length;$i++){
$ext='';
$m=[regex]::match($files[$i],'\.[^\.]+$');
if($m.Success){$ext=$m.groups[0].value;}
if($i -lt $text.Count){
$newname=$text[$i]+$ext;
$files[$i]+$c+$newname;
}
}
}

❼ 如何利用txt文档或word文档或excel文档里写好的文档给文件批量重命名

如果只是4个文件,简单了。在TXT文本中输入:
ren 1.jap qwe.jap
ren 2.jap asd.jap
ren 3.jap zxc.jap
ren 4.jap rty.jap
(注意:中间有空格。)保存为bat文件(将TXT后缀改为bat),然后运行一下就行。
如果文件名称较多,则新建一个EXCEL文件
在A列每个单元格输入:ren空格
B列输入原来的文件名称如:1.jap空格
C列输入改后的文件名称如:qwe.jap
在D1输入:=A1&B1&C1,下拉公式。(以上空格不能省略)
复制D列数据,粘贴到新的TXT文件里,保存为bat文件(将TXT后缀改为bat),然后运行一下就行。

❽ 批处理按txt列表重命名文件bat代码

不清楚你的实际文件/情况,仅以问题中的样例说明及猜测为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI,跟要处理的文件放一起双击运行
<# :
cls
@echo off
rem 将当前目录里的多个文件按照原有排序分别重命名为不同名称
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
cd /d "%~dp0"
powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::GetEncoding('GB2312')))) -Args '%~f0'"
echo;%#% +%$%%$%/%@% %z%
pause
exit
#>
$namelist=@"
lisi
zhangsan
maliu
wangwu
"@;
$codes=@'
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public static class ExpDir
{
[DllImport("Shlwapi.dll", CharSet=CharSet.Unicode)]
public static extern int StrCmpLogicalW(string p1, string p2);
public static string[] Sort(string[] f)
{
Array.Sort(f, StrCmpLogicalW);
return f;
}
}
'@;
Add-Type -TypeDefinition $codes;
$arr=$namelist.trim() -split '[\r\n]+';
[byte[]]$b=@(32,45,45,62,32);
$c=[Text.Encoding]::Default.GetString($b);
$self=get-item -liter $args[0];
$path=$self.Directory.FullName;
$files=@(dir -liter $path|?{($self.Name -ne $_.Name) -and ($_ -is [System.IO.FileInfo])}|%{$_.Name});
if($files.length -ge 1){
$brr=[ExpDir]::Sort($files);
for($i=0;$i -lt $brr.length;$i++){
$f=get-item -liter $brr[$i];
if($i -lt $arr.length){
$newname=$arr[$i]+$f.Extension;
$brr[$i]+$c+$newname;};};}