I have a known filetype (blendfile) and I want to write the associated application path into a .txt file (in the same folder as the batch script).
So for example, for a .txt file I'm using:
ftype blendfile >> "%~dp1BlenderPath.txt"
Which gives me an output of:
blendfile="C:\Program Files\Blender Foundation\Blender 2.83\blender.exe" "%1"
But I only want the "C:\Program Files\Blender Foundation\Blender 2.83\blender.exe"
part written into the text file.
How do I achieve this?
(EDIT: Edited question to be specific to the filetype path I was looking for)
For the blendfile, try:
@echo off
for /f tokens^=1^,2delims^=^=^" %%i in ('ftype blendfile') do echo "%%~j"
ftype
stores various formats, so this particular item will not work for all ftype
entries.
So to get all of the ftype values, you need a bit of a hack. For the amount of time I have, this is the best I can do:
@echo off
setlocal enabledelayedexpansion
(for /f tokens^=1^,2*delims^=^=^/^" %%i in ('ftype') do (
set "str=%%~j"
set "str=!str: %%1=!"
set str="!str!"
set "str=!str: "="!"
echo !str!
)
)>"%~dp1BlenderPath.txt"