T
T
Tenebrius2018-07-05 18:04:39
cmd/bat
Tenebrius, 2018-07-05 18:04:39

How to escape paths in "dir"?

The command diroutputs a string like "C:\path\to\file.mp3"
I need to get the string "C:\\path\\to\\file.mp3"
or
"C:/path/to/file.mp3"
Like this can be done?
More globally, there is a bat file:

@echo off
chcp 65001 
dir /s/b > DB.txt

Which outputs a list of folders and files to a text file. This is where you need either double backslashes or regular slashes.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2018-07-05
@Tenebrius

see set /?

set "fulldir=С:\path\to\file.mp3"
set "fulldir=%fulldir:\=\\%"
или
set "fulldir=%fulldir:\=/%"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question