Search found 4 matches
- 05 Dec 2024 03:21
- Forum: DOS Batch Forum
- Topic: Split a filename containing wildcards in path and name without expanding the wildcards
- Replies: 6
- Views: 2057
Re: Split a filename containing wildcards in path and name without expanding the wildcards
Thanks for the suggestion. If you escape * and ? in the command line with ^^* and ^^? then %~nx1 works. But if you write * and ? directly in the command line (without escaping them), the problem is to escape these characters inside the bat script. ? can be easily escaped with string substitution: se...
- 01 Dec 2024 21:41
- Forum: DOS Batch Forum
- Topic: Split a filename containing wildcards in path and name without expanding the wildcards
- Replies: 6
- Views: 2057
Split a filename containing wildcards in path and name without expanding the wildcards
I want to split a filename that contains wildcards in "drive:path" and "name.ext" For example: @echo off echo path=%~dp1 echo name=%~nx1 It works if the filename does not contain wildcards, i.e. with filename=c:\mypath\myname.ext you get path=c:\mypath\ name=myname.ext But it does not work if the fi...
- 01 Dec 2024 12:47
- Forum: DOS Batch Forum
- Topic: Substring extraction fails in reverse order
- Replies: 2
- Views: 1894
Re: Substring extraction fails in reverse order
Very clever solution, exactly what I need.
Thanks
Thanks
- 29 Nov 2024 18:12
- Forum: DOS Batch Forum
- Topic: Substring extraction fails in reverse order
- Replies: 2
- Views: 1894
Substring extraction fails in reverse order
Hi, I want to extract all the characters, char by char, contained in a variable, without knowing the length of the string. For example using the syntax for substring extraction and extracting from left to right: set str=ABC set c=%str:~0,1% gives in var c the first char A, ..., set c=%str:~2,1% give...