Search found 125 matches

by pstein
23 Feb 2022 09:42
Forum: DOS Batch Forum
Topic: How to remove a path from all lines in file? Filenames should be kept.
Replies: 1
Views: 5346

How to remove a path from all lines in file? Filenames should be kept.

In a text file many lines contain a path + filename each

How can I (from a DOS Batch script) remove all the paths (including the last \") from all lines which contain a path+filename?
Just the filename should remain.

If a line is empty or contain just other text then nothing should happen.
by pstein
11 Aug 2021 15:33
Forum: DOS Batch Forum
Topic: rename file name beginning with a pattern until (unknown) end?
Replies: 4
Views: 4233

rename file name beginning with a pattern until (unknown) end?

Ok, I can rename a filename and replace a certain pattern by another pattern with a (simplified) command like: set "search=foobar" set "replace=newpattern" set "fname=aaa bbb foobar ccc ddd" ren "!fname!" "!fname:%search%="%replace%!" which yields as new filename: aaa bbb newpattern ccc ddd It works...
by pstein
23 Feb 2021 23:02
Forum: DOS Batch Forum
Topic: "msg" command runs from CmdPrompt but not from batch script
Replies: 3
Views: 6950

"msg" command runs from CmdPrompt but not from batch script

When I enter the command msg Peter /TIME:0 hello on command line CmdPrompt then everything is ok. A popup info box appears with the message "hello". When I execute the same command from inside a DOS batch script then I got an error: 'msg' is not recognized as an internal or external command, operabl...
by pstein
18 Sep 2020 02:21
Forum: DOS Batch Forum
Topic: How to pass "chcp 1252" command to START "" /B /WAIT program?
Replies: 4
Views: 7116

Re: How to pass "chcp 1252" command to START "" /B /WAIT program?

Yields popup "Windows cannot find '>nul chcp 1252 & ......' Make sure you typed the name correctly and then try again" Same with start "" /NORMAL /B /WAIT ">nul chcp 1252 && D:\foobar\myprog.exe /parm1 /parm2 someparm” or start "" /NORMAL /B /WAIT ">nul chcp 1252" & D:\foobar\myprog.exe /parm1 /parm...
by pstein
17 Sep 2020 03:27
Forum: DOS Batch Forum
Topic: How to pass "chcp 1252" command to START "" /B /WAIT program?
Replies: 4
Views: 7116

How to pass "chcp 1252" command to START "" /B /WAIT program?

I am running a batch script. Part of this batch script is the call of an external cmdline-only program. I start this program from batch script with start "" /NORMAL /B /WAIT D:\foobar\myprog.exe /parm1 /parm2 someparm It works. However the output of that program contains german Umlaute which are not...
by pstein
31 Aug 2020 07:59
Forum: DOS Batch Forum
Topic: Easiest way to rename parts of filenames? NO regular expressions needed
Replies: 7
Views: 7045

Re: Easiest way to rename parts of filenames? NO regular expressions needed

It work. Thank you

Where can I find the syntax of the replacement command you used:

"<sourcefilename>:<frompattern>=<replacepattern>"

When I type

ren /?

this is not mentioned
by pstein
30 Aug 2020 09:47
Forum: DOS Batch Forum
Topic: Easiest way to rename parts of filenames? NO regular expressions needed
Replies: 7
Views: 7045

Re: Easiest way to rename parts of filenames? NO regular expressions needed

Thank you, it works. One last question: I want to apply the script onto another directory and wrote for %%i in ("D:\\indata\\new\\*%search%*.*") do ( ....) resp for %%i in ("D:\indata\new\*%search%*.*") do ( ....) But none of the two methods work. How do I let the script work with other directories ...
by pstein
30 Aug 2020 06:31
Forum: DOS Batch Forum
Topic: Easiest way to rename parts of filenames? NO regular expressions needed
Replies: 7
Views: 7045

Re: Easiest way to rename parts of filenames? NO regular expressions needed

Hello Steffen,

thank you for the code. It works for most of the cases.
However when the source file pattern contains german Umlaute (like ÄÜÖ) it doesn't work.
Example

set "search= Änderung rel3 "
set "replace= change old"
.....

Any way to handle this as well?

Peter
by pstein
29 Aug 2020 07:14
Forum: DOS Batch Forum
Topic: Easiest way to rename parts of filenames? NO regular expressions needed
Replies: 7
Views: 7045

Easiest way to rename parts of filenames? NO regular expressions needed

Occasionally I have to rename masses of files resp. a part of their filename. Only pattern REPLACEMENTS are should take place. NO inserts, NO deletions and no regular expression replacements. Just simple replacements. This should be done from inside a script. So is there an easy way to rename e.g. t...
by pstein
16 Jul 2020 05:27
Forum: DOS Batch Forum
Topic: Assign cmdline output to var with inner cmdline quotes?
Replies: 10
Views: 10457

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: 10457

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: 10457

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: 10457

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: 9699

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: 9699

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"