开发者

Deleting files that are listed in a csv file

开发者 https://www.devze.com 2023-03-02 20:33 出处:网络
We have hundreds of thousands of indexed files in folders that are broken up by days. 开发者_StackOverflow中文版 We have a list of filenames on a csv file that we need to delete.What script can I use

We have hundreds of thousands of indexed files in folders that are broken up by days. 开发者_StackOverflow中文版 We have a list of filenames on a csv file that we need to delete. What script can I use to look up these files and delete them? If forfiles worked, what would the script look like? We are using Windows Server.


If your CSV does not contain quoted values for should be able to deal with it. E.g. if the file names are in the second column of the file:

for /f "tokens=2 delims=," %%f in (foo.csv) do del "%%f"

It'd be helpful if we knew how your file looked like, though.


You'd be much better off using powershell, if it's available, as that has the facility to open CSV files out of the box.

import-csv is your best bet, and you don't need a powershell console - you can integrate powershell into an existing batch script by just calling powershell.exe from the command line and invoking cmdlets and scripts from there.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号