Batch: Include the content of a text file in a variable.

Solved
Nicodelamort Posted messages 13 Status Member -  
Nicodelamort Posted messages 13 Status Member -
```plaintext Hello, I would like to include the content of a text file in a variable without including the last 7 characters.
Let me explain: the file contains a path as well as the filename.
That is to say like this: C:\[path]\XXX.extension
I know how to include the entire content of the file
set /p Var= < file.txt

But I have no idea how to remove the last 7 characters :/
I hope my explanations are clear and I thank you in advance. ```

1 answer

  1. dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   5 660
     
    bonjour
    C:> set /p var=<fichier.txt
    C:> echo %var%
    C:\[chemin]\XXX.extention
    C:> set var=%var:~0,-7%
    C:> echo %var%
    C:\[chemin]\XXX.ex
    2
    1. Nicodelamort Posted messages 13 Status Member 2
       
      Thank you very much!
      I was saying to myself that it was possible but I couldn't remember that command :-)
      0