更新时间:2023-12-01 10:36:22
选项1:使用Windows PowerShell
打开Windows菜单. 键入:"PowerShell",然后打开"Windows PowerShell"命令窗口.
Open the windows menu. Type: "PowerShell" and open the 'Windows PowerShell' command window.
转到带有所需文件的文件夹:例如cd"C:\ house家务劳动" 注意:如果涉及空格,地址必须包含引号".
Goto folder with desired files: e.g. cd "C:\house chores" Notice: address must incorporate quotes "" if there are spaces involved.
您可以使用'dir'查看文件夹中的所有文件.使用"|"将通过管道传递以下命令的"dir"输出.
You can use 'dir' to see all the files in the folder. Using '|' will pipeline the output of 'dir' for the command that follows.
注意:'dir'是'Get-ChildItem'的别名.请参阅: Wiki:cmdlet . 一个可以提供进一步的功能.例如'dir -recurse'输出所有文件,文件夹和子文件夹.
Notes: 'dir' is an alias of 'Get-ChildItem'. See: wiki: cmdlets. One can provide further functionality. e.g. 'dir -recurse' outputs all the files, folders and sub-folders.
如果我只想要一系列文件怎么办?
What if I only want a range of files?
代替"dir |"我可以使用:
Instead of 'dir |' I can use:
dir | where-object -filterscript {($_.Name -ge 'DSC_20') -and ($_.Name -le 'DSC_31')} |
对于以目录名作为前缀的批量重命名:
For batch-renaming with the directory name as a prefix:
dir | Rename-Item -NewName {$_.Directory.Name + " - " + $_.Name}
选项2:使用命令提示符
在文件夹中,按shift +右键单击:选择在此处打开命令窗口"
In the folder press shift+right-click : select 'open command-window here'
for %a in (*.*) do ren "%a" "prefix - %a"
如果文件很多,***在此之前添加一个'@echo off'命令,并在末尾添加一个'echo on'命令.
If there are a lot of files, it might be good to add an '@echo off' command before this and an 'echo on' command at the end.