0

I'm trying to make a batch file that will read a text file (Net.txt) to pull a datapath from it. Assign it to a variable then empty a file from a nearby location.

Net.txt looks like

 SharedPath=C:\Program\2017\
 SharedUNC=C:\Program\2017\

Then find the directory and delete files with a specific extension.

cd %variable%\OPTION\trash
DEL *.xxx

This works great locally when everything is on C: but I don't think batch/cmd supports UNC paths. Is there a better language to use?

Radeo
  • 1
  • 1
  • 1
    Might still be possible with batch-file: [How to run batch file from network share without “UNC path are not supported” message?](https://stackoverflow.com/q/9013941/2745495) – Gino Mempin Jan 25 '19 at 03:18

1 Answers1

1

To read a file line by line, use a for /f loop.
The following code assumes net.txt to be exactly as shown in your question and will delete the files in both the SharedPath and the SharedUNC (should they differ; if they are the same, del will spit an error for the second one (which you can suppress with 2>nul))

for /f "tokens=2 delims==" %%a in (net.txt) do del "%%aOPTION\trash\*.xxx"

If that is not what you want, please describe your problem in more detail.

Stephan
  • 53,940
  • 10
  • 58
  • 91