當前位置:首頁 » 網頁前端 » 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;};};}