Search found 116 matches

by pstein
16 Jul 2020 05:27
Forum: DOS Batch Forum
Topic: Assign cmdline output to var with inner cmdline quotes?
Replies: 10
Views: 603

Re: Assign cmdline output to var with inner cmdline quotes?

No, you didn't understand me. You simply wrote (`Command`). But what if the Command in turn contains inside further, nested double quotes? Double quotes are sometimes required if the path to a program contains blanks (see here the blank between bbb and ccc). If I write for example: For /F "Tokens=* ...
by pstein
15 Jul 2020 04:05
Forum: DOS Batch Forum
Topic: Assign cmdline output to var with inner cmdline quotes?
Replies: 10
Views: 603

Re: Assign cmdline output to var with inner cmdline quotes?

Again: This does not help. When I code in the dos batch script: For /F "usebackq tokens=*" %%G in ('"D:\aaa\bbb cccc\ddd eee\myprog.exe" -parm1 "https://www.foobar.com/web/page/targetpage/q=$subparm" xxxx.jpg') Do Set "Var=%%G" I am getting an abort: "D:\aaa\bbb is not recognized as an internal or e...
by pstein
14 Jul 2020 00:27
Forum: DOS Batch Forum
Topic: Assign cmdline output to var with inner cmdline quotes?
Replies: 10
Views: 603

Re: Assign cmdline output to var with inner cmdline quotes?

You are partially right. I wrote down the %$set% assignment trick in the past but did not found not the working example in my archive. Anyway I am still searching for a way to assign the output of a command to a batch variable otherwise. For /F "Tokens* UsebackQ" %%G in (`"D:\aaa\bbb cccc\ddd eee\my...
by pstein
12 Jul 2020 02:00
Forum: DOS Batch Forum
Topic: Assign cmdline output to var with inner cmdline quotes?
Replies: 10
Views: 603

Assign cmdline output to var with inner cmdline quotes?

Assume I have a cmdline command simplified as follows: "D:\aaa\bbb cccc\ddd eee\myprog.exe" -parm1 "https://www.foobar.com/web/page/targetpage/q=$subparm" xxxx.jpg Since the program path contains blanks it must be enclosed in double quotes. The command above works in CmdPrompt on 64bit Win7 Now I wa...
by pstein
28 Feb 2020 03:14
Forum: DOS Batch Forum
Topic: How to replace extension of a filename stored in variable?
Replies: 6
Views: 3966

Re: How to replace extension of a filename stored in variable?

Ok, it works now, but only in the simplest scenario. My original problem is derived from a more complex script: @echo off &setlocal DisableDelayedExpansion setlocal EnableDelayedExpansion .... set "file1=C:\somewhere\foo.bar" for %%i in ("%file1%") do set "newfile1=%%~dpni.png" echo newfile1=%newfil...
by pstein
28 Feb 2020 02:02
Forum: DOS Batch Forum
Topic: How to replace extension of a filename stored in variable?
Replies: 6
Views: 3966

Re: How to replace extension of a filename stored in variable?

Hmm, dann bekomme ich ein Abort mit:

The following usage of the path operator in batch-parameter
substitution is invalid: %~dpni.png"
by pstein
28 Feb 2020 01:10
Forum: DOS Batch Forum
Topic: How to replace extension of a filename stored in variable?
Replies: 6
Views: 3966

How to replace extension of a filename stored in variable?

I have a variable %file% which contains a filename including drive and path. Now I want to replace the extension of this filename (whatever it is) and append .png to it. If the filename would be stored in a numeric system variable %1 I could write something like set newfile=%~dpn1.png But what if th...
by pstein
27 Dec 2019 01:39
Forum: DOS Batch Forum
Topic: How to rename parts of filenames with certain target patterns?
Replies: 1
Views: 1311

How to rename parts of filenames with certain target patterns?

How can I (from cmdline!) rename parts of filename (and leave the remaining part untouched)? Simplified example: Assume I have the following files: test aabb cc 13412542552.pdf second aabb cc 324236236.pdf other aabb cc 2345325.pdf Now I want to replace the pattern " aabb cc " by " (newpattern 2019)...
by pstein
24 Sep 2019 09:56
Forum: DOS Batch Forum
Topic: Search and insert multi-line pattern in text file?
Replies: 2
Views: 6867

Search and insert multi-line pattern in text file?

Assume I have 3 text files: 1st file "searchpattern.txt" which contains one or multiple text lines with a text pattern to search 2nd file "insertpattern.txt" which contains one or multiple text lines with a text pattern to insert 3rd file "targetfile.txt" which may contain the searchpattern and wher...
by pstein
22 Aug 2019 13:10
Forum: DOS Batch Forum
Topic: How to use command output in echo? assign cmd output to var?
Replies: 2
Views: 3023

How to use command output in echo? assign cmd output to var?

For simplicity lets talk about a simple command- When I enter the following command at the CmdPrompt: vol D: the volume name is shown. But what it I want to use the output in an echo command? Lets say I want to code something like echo volume of D=vol D: does not work. How else can I achieve it? Or ...
by pstein
28 Nov 2018 05:15
Forum: DOS Batch Forum
Topic: How to I replace " by ' " (at the start and end of a string in a variable)? Doubling Backslashes?
Replies: 4
Views: 1483

How to I replace " by ' " (at the start and end of a string in a variable)? Doubling Backslashes?

Assume I have a variable with a double quote enclosed string inside. Most simplified by a manual assigment like set myfile="D:\foo\bar\aaa\bbb.txt" How can I most easily replace the two enclosing " by ' ? How can I most easily replace the embedded single backslashes \ by double backslashes? Afterwar...
by pstein
28 Nov 2018 05:10
Forum: DOS Batch Forum
Topic: How to create an UTF-8 file (instead of UCS-2 Little Endian)?
Replies: 3
Views: 1462

How to create an UTF-8 file (instead of UCS-2 Little Endian)?

Wehn I issue from a DOS batch file the following command:

echo foobar >myfile.txt

then myfile.txt will always be created as UCS-2 Little Endian based file

How can I tell the DOS batch execution to create an UTF-8 file instead?

Peter
by pstein
17 Nov 2018 10:28
Forum: DOS Batch Forum
Topic: How to pass params (=files) in the order I clicked them in Winexp?
Replies: 5
Views: 1403

How to pass params (=files) in the order I clicked them in Winexp?

Assume I have (simplified) three files in a directory: 111.txt 222.txt 333.txt Now I click and mark (step by step) the files in the sequence 333.txt then 111.txt and finally 222.txt Afterwards I dragged the three marked files on a DOS batch shortcut on desktop for further processing. Unfortunately t...
by pstein
23 Sep 2018 03:04
Forum: DOS Batch Forum
Topic: Find recursively (!) all empty dirs below top folder?
Replies: 3
Views: 1868

Re: Find recursively (!) all empty dirs below top folder?

@CirothUngol Thank you for your suggestion. You are right: Finally I want to remove all empty folders. But at first I want to list them only. Unfortunately your code produces an error: File Not Found ')ELSE' is not recognized as an internal or external command, operable program or batch file. Whats ...