简体   繁体   English

如何打印文件夹中所有文件的名称

[英]how can I print the name of all files from a folder

I have like 10000 files in a folder and I want to know which one is doublicated. 我在一个文件夹中有10000个文件,我想知道哪个文件是重复的。 I like to save only the names of them in a txt file 我只想将它们的名称保存在txt文件中

Is there any way to do it? 有什么办法吗?

My files look like this. 我的文件如下所示。 as an example 举个例子

..._P2_A1-(01)_....tx

For me it is doublicated when I have the first part twice QEX2_P2_A1 对我来说,当第一部分获得两次QEX2_P2_A1

I did try to print it but with no success for example, here is one solution Bash: How to print the filename of the nth file in a folder or Extract filename and extension in Bash which did not work for me. 我确实尝试打印它,但是没有成功,例如,这是Bash的一种解决方案:如何在文件夹中打印第n个文件的文件 名或在Bash中提取文件名和扩展名,这对我不起作用。 I have tried to search it but I could not find any solution 我尝试搜索它,但找不到任何解决方案

You can use printf + awk to print all partially duplicated filenames: 您可以使用printf + awk打印所有部分重复的文件名:

printf "%s\n" *.txt | awk -F '_' '{k=$1 FS $2 FS $3} k in seen{dups[seen[k]]=k; dups[$0]=k}
  {seen[k]=$0} END{for (f in dups) print dups[f] " => " f}'

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

相关问题 如何复制文件夹中的所有文件并更改同一目录中的名称? - How can i copy all the files in a folder and change the name in the same directory? 如何打印目录的倒数第二个文件夹的名称? bash - How can I print the name of the antepenultimate folder of a directory? bash 如何根据文件名将一个文件夹中的多个文件分成不同的文件夹? - How can I separate many files from one folder into separate folders based on the name of the files? 如何从......到打印文件名 - How to print files name from… to 如何从多个文件夹中提取文件并根据文件夹名称 (bash) 重命名? - How can I extract files from multiple folders and rename according to folder name (bash)? 如何将文件从当前文件夹移动到上一个文件夹? - How can I move files from current folder to previous folder? 如何在文件中使用正则表达式打印所有匹配项? - How can I print all matches by regex in files? 如何删除具有特定名称的所有子目录中的所有文件? - How can I delete all files in all subdirectories with a certain name? 如何创建包含文件夹中所有文件名称的数组? - How can I creates array that contains the names of all the files in a folder? 如何重命名该文件夹名称的文件名并将所有文件复制到一个文件夹 - How to rename the filename of that folder name and copy all files into one folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM