Suppose I have a batch script that expects a folder path in argument %1. I want to append a file name to the path and use that in a command. Is there a simple w
I don't see a way to make it work for all the cases. Your solution will handle all the local paths cases, but to handle UNC or long paths it seems that it is necessary to first correct the path and then append the file data
@echo off
setlocal enableextensions disabledelayedexpansion
for /f "delims=" %%a in ("%~f1."
) do for /f "delims=" %%b in ("%%~fa\file.ext"
) do echo "%%~fb"
This "should" handle local, network or long paths (the reason for the for /f is the ?), both absolute and relative, and the posibility of no giving a path in the command line.