Using a CSV to delete entries without a match

Advanced Renamer forum
#1 : 17/08-20 02:10
Posts: 3
I have a .csv file with a bunch of names (no file extension). I have a folder with a lot of files with the same names, but also other files without any names listed in the .csv

The goal is to only keep the matches and delete the rest (or at least put them in their own folder to delete myself). How would I do this in Advanced Renamer?

17/08-20 02:10 - edited 17/08-20 02:35
#2 : 18/08-20 16:09
David Lee
David Lee
Posts: 662
Not a job for Advanced Renamer but easy to do with the command line.

Easiest and safest method will be to move the files that you want to keep and then delete the remainder - since files deleted from the command line (or batch script) do not go to the recycle bin.

eg - from a command prompt in the folder containing the files:

FOR /F "TOKENS=1" %f IN (list.csv) DO move %f.* "newFolderPath"

The new folder must exist otherwise the script will try to rename the moved files to the new folder name.

Also if you put this into a batch file you must replace each instance of "%" with "%%".

18/08-20 16:09 - edited 18/08-20 17:10