0

I have a directory (on my Mac) of 400,000 files and I have derived a list of 14,000 files that I would like to delete from that directory. The names of the files that need to be deleted match exactly the names in the "Files" directory, which all happen to be .txt. I have searched everywhere for a way to do this with no success.

-- Folder on Mac called "Letters" containing .txt files called, for example --

Letter_1925_1_1_1.txt

Letter_1937_15_5_3.txt

Letter_1950_99_8_2.txt

Letter_1951_7_18_1.txt

Letter_1968_64_19_1.txt

Letter_1983_88_4_2.txt

Letter_1990_12_22_4.txt

Letter_1995_90_10_2.txt

-- A CSV and/or TXT file with names that need to be deleted --

Letter_1925_1_1_1.txt

Letter_1968_64_19_1.txt

Letter_1990_12_22_4.txt

Letter_1995_90_10_2.txt

-- After running some sort of process, I would like the directory to only contain the following files --

Letter_1937_15_5_3.txt

Letter_1950_99_8_2.txt

Letter_1951_7_18_1.txt

Letter_1983_88_4_2.txt

As I am learning to be more technical, I would prefer to find this solution either in Mac Terminal or in R. Thanks everyone!

EAG_NYC
  • 11
  • 1
  • 4
    What have you tried so far? Please include your code attempt. – Maurits Evers Jul 17 '18 at 00:11
  • Go to a terminal in Mac. Assuming that you have the complete set of file that you want to delete in one folder and the file contains only files with suffix *.txt, run the following command: rm -rf [/your/path/] *.txt. Depending on your permissions for that folder, you might need to also add sudo at the beginning of the line. – Toolbox Aug 06 '18 at 06:14

0 Answers0