Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Charla

macrumors newbie
Original poster
Feb 20, 2012
18
2
Brisbane, Australia
Hi clever people,
I have a text document listing around 3700 filenames/paths. Is there any way to select and delete all of these files?
On a MacBook Pro running OS10.13.6. The files I want to delete are on an external volume of my NAS if this makes any difference.
Thanks in advance!
 

DeltaMac

macrumors G5
Jul 30, 2003
13,476
4,410
Delaware
Assuming all the pathnames are complete and accurate (and probably needs to be in a format that is acceptable to the Finder), there should be a way to delete all the files with an Automator action.

Also, I would suggest looking at Hazel by Noodlesoft. It excels at file management tasks.
(caveat - I don't use Hazel, but I often see it mentioned first when questions about file management come up.)
 
  • Like
Reactions: Charla

Slartibart

macrumors 68030
Aug 19, 2020
2,893
2,597
Make sure the NAS partition with the files you want to delete is mounted. Make sure that the list is a plain text file (ASCII, not RTF). Let’s assume this is called ListOfFiles.txt. ?

Open a terminal.

In the terminal change to the folder where you saved ListOfFiles.txt:

cd /where/ever/you/saved/it/

then use the following to delete all files from that list:

for i in $(cat ./ListOfFiles.txt); do rm -f $i done
 
  • Like
Reactions: bogdanw and Charla

Charla

macrumors newbie
Original poster
Feb 20, 2012
18
2
Brisbane, Australia
Make sure the NAS partition with the files you want to delete is mounted. Make sure that the list is a plain text file (ASCII, not RTF). Let’s assume this is called ListOfFiles.txt. ?

Open a terminal.

In the terminal change to the folder where you saved ListOfFiles.txt:

cd /where/ever/you/saved/it/

then use the following to delete all files from that list:

for i in $(cat ./ListOfFiles.txt); do rm -f $i done
Cheers Slartibart, that looks completely terrifying but I'll give it a go! (with a sample dozen first) ?. Thanks so much, will let you know how I get on.
C
 

Slartibart

macrumors 68030
Aug 19, 2020
2,893
2,597
Cheers Slartibart, that looks completely terrifying but I'll give it a go! (with a sample dozen first) ?. Thanks so much, will let you know how I get on.
C
if you have to work with plain text files I highly recommend BBedit. Even in freemode this is one of the grand programs for the Mac.
 
  • Like
Reactions: Charla

Charla

macrumors newbie
Original poster
Feb 20, 2012
18
2
Brisbane, Australia
if you have to work with plain text files I highly recommend BBedit. Even in freemode this is one of the grand programs for the Mac.
Ah yes, used to be Text Wrangler? I loved that app. Will try it... so far no luck with the Terminal command but will triple check things my end before posting again for help!
 

Slartibart

macrumors 68030
Aug 19, 2020
2,893
2,597
Ah yes, used to be Text Wrangler? I loved that app.

yes. this was previously Textwrangler.

Will try it... so far no luck with the Terminal command but will triple check things my end before posting again for help!

1.) the line endings in your textfile might mess up the terminal command. you can fix that with BBedit. 2.) directory names in the path which include spaces require some modification in the shell script. 3.) you can try to add rm -f before a single file path to see wether it works. 4.) you might need to use sudo to execute the terminal command.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.