0

I was attempting to display the contents of a file if the user type /d for the first argument of my command.

However all it would display is 'The system cannot find the file specified. Data:'

Using 'set "_path=%~dp0"' in my other batch files worked but not here, why, and how do I fix it?

@echo off
if "%1"=="/d" (
     set "_path=%~dp0"
     set data_txt=<%_path%user.txt
     echo Data: %data_txt%
)
Zeeen
  • 312
  • 1
  • 2
  • 13
  • `set data_txt=<%_path%user.txt` should be `set /p data_txt=<%_path%user.txt`, notice the `/p` switch – Nico Nekoru Jul 24 '20 at 04:52
  • If you only want to display the file's content if the user select `/d` then why not try just this simple line? `@if "%~1"=="/d" @type "%~dp0user.txt"` – Gerhard Jul 24 '20 at 05:56
  • Thankyou everybody for your help, not only did I fix my code, I realized how bad I am at coding with batch lol – Zeeen Jul 24 '20 at 13:02

0 Answers0