Can someone write me a batch file to replace full stops in filenames, please?
Moderator: DosItHelp
Can someone write me a batch file to replace full stops in filenames, please?
Some time back I asked on a forum (this one, I think, but I can't find the post) for a batch file that would replace underscores in a filename with a space, and someone was kind enough to create this batch file::
@echo off
setlocal enabledelayedexpansion
for %%a in (*_*) do (
SET "file=%%a"
ren "!file!" "!file:_= !"
)
It works very well, but can I request someone to create two new batch files, please. Both should do largely the same thing, but the second one is more selective of the full stops it replaces. The two batch files I'd like would be:
1) A batch file that replaces all full stops (or periods, as American's say) in the filenames with a space, EXCEPT for the final full stop, since of course that final one marks the beginning of the file's extension.
2) The same as in number 1, except that it doesn't replace any full stop that's between two numerical characters, or that follows the letter 'v' or the word 'version'. This is so that the date or version information in the filename is not altered.
For number 2, the results would be:
catgen.v1.0.zip becomes catgen v1.0.zip (just one full stop becomes a space)
win.dirreplac.v.3.rar becomes win dirreplac v.3.rar (two full stops become spaces)
t.c.s.2012.08.05.zip becomes t c s 2012.08.05.zip (three full stops become spaces)
win.n64check.version.4.25.zip becomes win n64check version.4.25.zip (two full stops become spaces)
Thanks for reading this, and for any answers.
@echo off
setlocal enabledelayedexpansion
for %%a in (*_*) do (
SET "file=%%a"
ren "!file!" "!file:_= !"
)
It works very well, but can I request someone to create two new batch files, please. Both should do largely the same thing, but the second one is more selective of the full stops it replaces. The two batch files I'd like would be:
1) A batch file that replaces all full stops (or periods, as American's say) in the filenames with a space, EXCEPT for the final full stop, since of course that final one marks the beginning of the file's extension.
2) The same as in number 1, except that it doesn't replace any full stop that's between two numerical characters, or that follows the letter 'v' or the word 'version'. This is so that the date or version information in the filename is not altered.
For number 2, the results would be:
catgen.v1.0.zip becomes catgen v1.0.zip (just one full stop becomes a space)
win.dirreplac.v.3.rar becomes win dirreplac v.3.rar (two full stops become spaces)
t.c.s.2012.08.05.zip becomes t c s 2012.08.05.zip (three full stops become spaces)
win.n64check.version.4.25.zip becomes win n64check version.4.25.zip (two full stops become spaces)
Thanks for reading this, and for any answers.
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Can someone write me a batch file to replace full stops in filenames, please?
You're deliberately putting spaces in file names? Ew, why? That's the exact opposite of what I recommend people should do.
But for script 1, just replace the _ in the ren line of your existing code with a space.
Script 2 is to complicated for me to write right now since I'm posting from my phone.
But for script 1, just replace the _ in the ren line of your existing code with a space.
Script 2 is to complicated for me to write right now since I'm posting from my phone.
Re: Can someone write me a batch file to replace full stops in filenames, please?
ShadowThief wrote:You're deliberately putting spaces in file names? Ew, why? That's the exact opposite of what I recommend people should do.
Why? I've never had problems with spaces in filenames, as far as I can remember. Do you mean because DOS might have problems? If so, I understand, but I just use Windows, well, aside from the odd batch file like this, which is necessary since Windows is only thirty plus years old so it's fair enough that amongst all the bloat Microsoft have never thought "Hang on, let's put something actually useful in the next version of Windows, like a comprehensive rename that's friendly and reliable..."
Gotta love Microsoft
But for script 1, just replace the _ in the ren line of your existing code with a space.
I can't check (I'm at work at the moment), but would that replace the "." (full stop) with a " " (space)? Even if it does, then won't it also change the final, pre-extension full stop, so, for example:
gameaddon.zip
would become:
gameaddon zip
which isn't what I want.
Script 2 is to complicated for me to write right now since I'm posting from my phone.
Oh, I can't stand typing on a mobile phone!
Re: Can someone write me a batch file to replace full stops in filenames, please?
You need to give us a better scope of your overall project?
It looks like you are trying to actually rename files? If not where are these file names coming from?
It looks like you are trying to actually rename files? If not where are these file names coming from?
Re: Can someone write me a batch file to replace full stops in filenames, please?
Squashman wrote:You need to give us a better scope of your overall project?
It looks like you are trying to actually rename files? If not where are these file names coming from?
Sorry, I wasn't clear. Yes, I just want to be able to run the batch file in my downloads folder, so that any files I've downloaded are renamed so that any full stop is replaced by a space, except for the last full stop (that denotes that the following characters are the file extension) or a full stop that follows a "v" or "version", or a full stop between numerical characters, i.e:
winut.tshv1.0.zip becomes winut tshv1.0.zip (just one full stop becomes a space)
version.05.gfx.utilty.tsk.rar becomes version.05 gfx utilty tsk.rar (three full stops become spaces)
So in the above, the full stop in "version.05" should stay, and the full stop in "1.0" should stay.
I'm using Windows 7.
Re: Can someone write me a batch file to replace full stops in filenames, please?
Here is part 1) from the first post.
John A
Code: Select all
@echo off
setlocal enabledelayedexpansion
for %%a in (*.*) do (
SET "fileN=%%~na"
SET "test=!fileN:.= !"
If /I "!test!" Neq "!fileN!" (
SET "fileE=%%~xa"
rem Code to further refine fileN goes here
Echo.ren "!fileN!!fileE!" "!fileN:.= !!fileE!"
)
)
John A
Re: Can someone write me a batch file to replace full stops in filenames, please?
thefeduke wrote:Here is part 1) from the first post.Code: Select all
@echo off
setlocal enabledelayedexpansion
for %%a in (*.*) do (
SET "fileN=%%~na"
SET "test=!fileN:.= !"
If /I "!test!" Neq "!fileN!" (
SET "fileE=%%~xa"
rem Code to further refine fileN goes here
Echo.ren "!fileN!!fileE!" "!fileN:.= !!fileE!"
)
)
John A
Thanks, but that's not working. When I run it (either by double clicking on the bat file, or by running it from a DOS box command line (not the emulator DOSBox, of course, I mean a DOS box in Windows 7), then I get the error
Invalid parameter(s)
CHANGE {LOGON | PORT | USER}
I've no idea what that error message means.
Re: Can someone write me a batch file to replace full stops in filenames, please?
I added some info with a pause at the end and double-clicked the file to get:Kerr Avon wrote:Invalid parameter(s)
CHANGE {LOGON | PORT | USER}
I've no idea what that error message means.
Code: Select all
ren "FindMyTitle.old.bat" "FindMyTitle old.bat"
ren "Full.Stops.v1.0.txt" "Full Stops v1 0.txt"
ren "FindMyTitle.ov.bat" "FindMyTitle ov.bat"
Running: D:\Yanci 16GB St\Scripts\FullStops.bat and the contents are:
@echo off
:: http://www.dostips.com/forum/viewtopic.php?f=3&t=7558&p=50201#p50201
setlocal enabledelayedexpansion
for %%a in (*.*) do (
SET "fileN=%%~na"
SET "test=!fileN:.= !"
If /I "!test!" Neq "!fileN!" (
SET "fileE=%%~xa"
rem Code to further refine fileN goes here
Echo.ren "!fileN!!fileE!" "!fileN:.= !!fileE!"
)
)
Echo.Running: %~0 and the contents are:
Type "%~0"
Ver
pause
Microsoft Windows [Version 10.0.14393]
Press any key to continue . . .
John A.
Re: Can someone write me a batch file to replace full stops in filenames, please?
Ver gives me:
Microsoft Windows [Version 6.1.7601]
Microsoft Windows [Version 6.1.7601]
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Can someone write me a batch file to replace full stops in filenames, please?
Google is implying that you had a file called change.something.something.bat and going from full stops to spaces somehow tried to treat the file name like a command and run it.
I know it doesn't make any sense, but that's the error message you get when you run the change command without following it with logon, port, or user.
I know it doesn't make any sense, but that's the error message you get when you run the change command without following it with logon, port, or user.
Re: Can someone write me a batch file to replace full stops in filenames, please?
ShadowThief wrote:Google is implying that you had a file called change.something.something.bat and going from full stops to spaces somehow tried to treat the file name like a command and run it.
I know it doesn't make any sense, but that's the error message you get when you run the change command without following it with logon, port, or user.
That problem seems to be gone! I was at work when I created this thread, and so couldn't try anything out on my desktop PC (which I use to download files). So when Thefeduke posted up that batch file, I copied some text files into a folder, renamed them to include more full stops, and the letter "v" followed by numbers, and numerical digits with a full stop between them, so I had a wide variety of filenames in that folder.
I then created a new text file in that directory, copied Thefeduke's batch file into the .txt file, and renamed it to r.bat. And when I ran r.bat I got the error message:
Invalid parameter(s)
CHANGE {LOGON | PORT | USER}
as I reported. I hadn't tried to run a program or batch file called 'change', I'm not even aware of such a file.
Anyway, after I arrive home, I turned my laptop back on, and re-run r.bat, and this time it worked! There was no error messages, no mention of a 'change' program or anything. This was same laptop I used at work (my own, I always take it to work for net surfing at luch and occasionally gaming), and the only difference was that when I used it at work, Microsoft Word was open, and prior to that I've been playing Deus Ex (plus a mod called GMDX) and hadn't restarted Windows when I ran the batch file.
Weird.
Anyway, at home the same batch file (literally the same one , I hadn't recreated it or edited it, it was the file that failed at work) worked, although it only printed on-screen what the renames should be, so I had to remove the highlighted "echo." from Thefeduke's routine:
@echo off
setlocal enabledelayedexpansion
for %%a in (*.*) do (
SET "fileN=%%~na"
SET "test=!fileN:.= !"
If /I "!test!" Neq "!fileN!" (
SET "fileE=%%~xa"
rem Code to further refine fileN goes here
Echo.ren "!fileN!!fileE!" "!fileN:.= !!fileE!"
)
)
so that that line is now
ren "!fileN!!fileE!" "!fileN:.= !!fileE!"
and it works!
Re: Can someone write me a batch file to replace full stops in filenames, please?
Anyway, I've put the two routines (the older one that swaps underscores for spaces, plus Thefeduke's one that swaps full stops for spaces, EXCEPT for the last full stop) into one batch file, and added a third routine to it (a modified version of the first one, that swaps two nonconsecutive spaces for one):
rem changes underscores to spaces
@echo off
setlocal enabledelayedexpansion
for %%a in (*_*) do (
SET "file=%%a"
ren "!file!" "!file:_= !"
)
rem changes full stops to spaces
@echo off
setlocal enabledelayedexpansion
for %%a in (*.*) do (
SET "fileN=%%~na"
SET "test=!fileN:.= !"
If /I "!test!" Neq "!fileN!" (
SET "fileE=%%~xa"
rem Code to further refine fileN goes here
ren "!fileN!!fileE!" "!fileN:.= !!fileE!"
)
)
rem changes double spaces to one space
@echo off
setlocal enabledelayedexpansion
for %%a in (* *) do (
SET "file=%%a"
ren "!file!" "!file: = !"
)
and I put the following files in a folder:
S.E.N.T.I.N.E.Lv2.5.TXT
Shadow_fire.txt
Sher.loc.k.txt
Silicon Dreams Novella.version1.2.txt
Skool-Daze_ Bugs.txt
SkoolDaze_historical.txt
SKOOLDAZv.1.TXT
Skool_Daze_ Trivia.txt
run the batch file, and I get the files renamed to:
S E N T I N E Lv2 5.TXT
Shadow fire.txt
Sher loc k.txt
Silicon Dreams Novella version1 2.txt
Skool Daze Trivia.txt
Skool-Daze Bugs.txt
SkoolDaze historical.txt
SKOOLDAZv 1.TXT
which is what I wanted! So, many thanks to Thefeduke and everyone for this. If anyone can modify it so that a full stop directly following a 'v' or a 'version' or in-between numerical characters will NOT be changed to a space then that would be great, but if not, then this is already fantastic.
Also, would it be possible to make these three routines work on files in subfolders too, like when you add '/s' to 'DIR', so that you get
dir /s
which makes dir work in all of the subfolders?
rem changes underscores to spaces
@echo off
setlocal enabledelayedexpansion
for %%a in (*_*) do (
SET "file=%%a"
ren "!file!" "!file:_= !"
)
rem changes full stops to spaces
@echo off
setlocal enabledelayedexpansion
for %%a in (*.*) do (
SET "fileN=%%~na"
SET "test=!fileN:.= !"
If /I "!test!" Neq "!fileN!" (
SET "fileE=%%~xa"
rem Code to further refine fileN goes here
ren "!fileN!!fileE!" "!fileN:.= !!fileE!"
)
)
rem changes double spaces to one space
@echo off
setlocal enabledelayedexpansion
for %%a in (* *) do (
SET "file=%%a"
ren "!file!" "!file: = !"
)
and I put the following files in a folder:
S.E.N.T.I.N.E.Lv2.5.TXT
Shadow_fire.txt
Sher.loc.k.txt
Silicon Dreams Novella.version1.2.txt
Skool-Daze_ Bugs.txt
SkoolDaze_historical.txt
SKOOLDAZv.1.TXT
Skool_Daze_ Trivia.txt
run the batch file, and I get the files renamed to:
S E N T I N E Lv2 5.TXT
Shadow fire.txt
Sher loc k.txt
Silicon Dreams Novella version1 2.txt
Skool Daze Trivia.txt
Skool-Daze Bugs.txt
SkoolDaze historical.txt
SKOOLDAZv 1.TXT
which is what I wanted! So, many thanks to Thefeduke and everyone for this. If anyone can modify it so that a full stop directly following a 'v' or a 'version' or in-between numerical characters will NOT be changed to a space then that would be great, but if not, then this is already fantastic.
Also, would it be possible to make these three routines work on files in subfolders too, like when you add '/s' to 'DIR', so that you get
dir /s
which makes dir work in all of the subfolders?
Re: Can someone write me a batch file to replace full stops in filenames, please?
Kerr Avon wrote:For number 2, the results would be:
catgen.v1.0.zip becomes catgen v1.0.zip (just one full stop becomes a space)
win.dirreplac.v.3.rar becomes win dirreplac v.3.rar (two full stops become spaces)
t.c.s.2012.08.05.zip becomes t c s 2012.08.05.zip (three full stops become spaces)
win.n64check.version.4.25.zip becomes win n64check version.4.25.zip (two full stops become spaces)
Code: Select all
@echo off
setlocal
for /f "delims=" %%a in ('dir /a-d/b') do if "%%~fa" neq "%~f0" (
setlocal enabledelayedexpansion
set "file=%%a"
set "ext=%%~xa"
call :sub "%%~na"
endlocal
)
endlocal
exit /b 0
:sub
set "var=%~x1"
(
echo.!var!| >nul findstr /irvx "\.v*[0-9]* \.version"
)&&(
set "beg=%~1"
if defined beg if defined end ren "%file%" "!beg:.= ! !end:*.=!%ext%"
)||(
set "end=%~x1%end%"
call :sub "%~n1"
)
exit /b 0
Re: Can someone write me a batch file to replace full stops in filenames, please?
Yury wrote:Kerr Avon wrote:For number 2, the results would be:
catgen.v1.0.zip becomes catgen v1.0.zip (just one full stop becomes a space)
win.dirreplac.v.3.rar becomes win dirreplac v.3.rar (two full stops become spaces)
t.c.s.2012.08.05.zip becomes t c s 2012.08.05.zip (three full stops become spaces)
win.n64check.version.4.25.zip becomes win n64check version.4.25.zip (two full stops become spaces)Code: Select all
@echo off
setlocal
for /f "delims=" %%a in ('dir /a-d/b') do if "%%~fa" neq "%~f0" (
setlocal enabledelayedexpansion
set "file=%%a"
set "ext=%%~xa"
call :sub "%%~na"
endlocal
)
endlocal
exit /b 0
:sub
set "var=%~x1"
(
echo.!var!| >nul findstr /irvx "\.v*[0-9]* \.version"
)&&(
set "beg=%~1"
if defined beg if defined end ren "%file%" "!beg:.= ! !end:*.=!%ext%"
)||(
set "end=%~x1%end%"
call :sub "%~n1"
)
exit /b 0
Thanks for that, but it's not working 100%, I'm afraid. If I use it with the following files:
C.O.B.R.A....TXT
Chaos - full text.txt
CITY_SIN_Fv.12.TXT
City_Slicker.txt
Colonyv.02.txt
Com b_____atLynx.txt
Contact Sam Cruise_ Bugs.txt
Contact Sam Cruise_ Trivia.txt
Contact.Sam.Cruiseversion1.0.txt
CR2 THE ESCAPE 48k-128k INSTRUCTIONS.txt
CR2 THE ESCAPE VEGA INSTRUCTIONS.txt
CR3 REPRISAL ZX INSTRUCTIONS v12.09 version23.txt
CR3 REPRISAL ZX INSTRUCTIONS v12.09.txt
then I get the following:
C.O.B.R.A....TXT
Chaos - full text.txt
CITY_SIN_Fv 12.TXT
City_Slicker.txt
Colonyv 02.txt
Com b_____atLynx.txt
Contact Sam Cruiseversion1 0.txt
Contact Sam Cruise_ Bugs.txt
Contact Sam Cruise_ Trivia.txt
CR2 THE ESCAPE 48k-128k INSTRUCTIONS.txt
CR2 THE ESCAPE VEGA INSTRUCTIONS.txt
CR3 REPRISAL ZX INSTRUCTIONS v12 09.txt
CR3 REPRISAL ZX INSTRUCTIONS v12.09 version23.txt
Which means "C.O.B.R.A....TXT" has unprocessed full stops (it should now be "COBRA .TXT"), "CITY_SIN_Fv.12.TXT" has wrongly had it's full stop (between the v and the 1) removed, "Colonyv.02.txt" has wrongly had the full stop removed, "Contact.Sam.Cruiseversion1.0.txt" has had the full stop between the 1 and 0 wrongly removed, and "CR3 REPRISAL ZX INSTRUCTIONS v12.09.txt" has had the full stop wrongly removed.
I've uploaded the files, to help you test the batch file.
Thanks.
- Attachments
-
- files to test renaming.zip
- (58.21 KiB) Downloaded 532 times
-
- Posts: 240
- Joined: 04 Mar 2014 11:14
- Location: germany
Re: Can someone write me a batch file to replace full stops in filenames, please?
this Script has everything including.
Dots become by your wishes blank character.
Low lines become blank character.
as a titbit all blank characters appearing one after the other several times Are summarised to one.
Blank characters at the beginning as well as at the end of the filename are deleted without comment.
In this Script it is also shown how "=" in a string with something is replaced.
(what goes with every other character * ~ etc. also)
This is necessary, so that on each other following blank characters can be summarised into the subroutine.
Oh what I still wanted to say: ECHO writes what would be renamed if you delete it.
Phil
Dots become by your wishes blank character.
Low lines become blank character.
... except that it doesn't replace any full stop that's between two numerical characters, or that follows the letter 'v' or the word 'version'.
This is so that the date or version information in the filename is not altered.
as a titbit all blank characters appearing one after the other several times Are summarised to one.
Blank characters at the beginning as well as at the end of the filename are deleted without comment.
In this Script it is also shown how "=" in a string with something is replaced.
(what goes with every other character * ~ etc. also)
This is necessary, so that on each other following blank characters can be summarised into the subroutine.
Code: Select all
@setlocal
:: rem - maybe you would like to test this Script?
@call :SETechoBack
@echo OFF
:: begin SCRIPT
rem - delete old variables
for /f "delims==" %%i in ('^(set bDot ^& set eDot^) 2^>nul ') do set "%%i="
rem - 12x begin multiply 10x end = 120x testings
set "bDot_a=version"
set "bDot_b=v"
for /l %%i in (0 1 9 ) do set /a bDot_%%i=eDot_%%i=%%i
rem - with operators OR, AND, Not only 22 tests are executed
rem - change into the Downlaod folder
pushD D:\test1
rem - list all files with more than 2 dots.
for /r %%I in ( "*.>??*.>???" "*_*") do (
%= rem -- the variable "I" contains a line number in this dot =%
%= to edit files. Hence, a pseudo line number is pasted. =%
set "Line=1:%%~nI"
set "readFile=%%~nI"
set "check="
setlocal enabledelayedexpansion
for /f "delims=:" %%N in ("!Line!") do (
%= rem N = Linenumber =%
%= rem -- I do not change this loop at this point, =%
%= so that the line number is processed of files. =%
endlocal
for /f "tokens=1-3 delims=[]" %%j in (
' cmd /u /von /c "echo !readfile!"^|find /n /v ""^|findstr "\. = _" ') do (
setlocal enabledelayedexpansion
%= rem set linebegin AA; Lineend ZZ
set "LineIn=!Line:*:=!"
set "Li_AA=!LineIn:~0,%%j!"
set "Li_AA=!Li_AA:~0,-1!"
set "Li_ZZ=!LineIn:~%%j!"
%= rem reset Errorlevel 0 =%
(call;)
if %%k equ . if defined Li_ZZ (
set "Li_a=!Li_AA:~-7!"
(call;)
%= rem check VAR before - bDot_a =%
if /i !Li_a! equ !bDot_a! (call)
%= rem check VAR bDot_b bdot_0-9 =%
set "Li_b=!Li_AA:~-1!"
if /i !Li_b! equ !bDot_b! (call)
if /i !Li_b! equ !bDot_0! (call)
if /i !Li_b! equ !bDot_1! (call)
if /i !Li_b! equ !bDot_2! (call)
if /i !Li_b! equ !bDot_3! (call)
if /i !Li_b! equ !bDot_4! (call)
if /i !Li_b! equ !bDot_5! (call)
if /i !Li_b! equ !bDot_6! (call)
if /i !Li_b! equ !bDot_7! (call)
if /i !Li_b! equ !bDot_8! (call)
if /i !Li_b! equ !bDot_9! (call)
if errorlevel 1 (
%= rem check VAR behind - eDot_b edot_0-9 =%
set "Li_e=!Li_ZZ:~0,1!"
(call;)
if /i !Li_e! equ !eDot_0! (call)
if /i !Li_e! equ !eDot_1! (call)
if /i !Li_e! equ !eDot_2! (call)
if /i !Li_e! equ !eDot_3! (call)
if /i !Li_e! equ !eDot_4! (call)
if /i !Li_e! equ !eDot_5! (call)
if /i !Li_e! equ !eDot_6! (call)
if /i !Li_e! equ !eDot_7! (call)
if /i !Li_e! equ !eDot_8! (call)
if /i !Li_e! equ !eDot_9! (call)
)
)
if not errorlevel 1 set "out= "
%= rem "=" should be edited ="
if %%k equ ^= set "out=?"
%= rem - if no combination of the previous characters =%
%= AND behind characters, then the dot is deleted =%
if not errorlevel 1 (
set "Outline=!Li_AA!!out!!Li_ZZ!"
for /f delims^= %%O in ("1:!outline!") do (
endlocal
set "Line=%%~O"
set "check=1"
)
) else endlocal
)
if defined check call :multiple_blank
)
)
call :checkCMDline "%~f0"
%EchoBack%
rem END TEST "%~nx0"
%CMDPause% exit /b
:: END script
:: begin SUBscript
:multiple_blank delete front multiple and back
if not defined Line >&2 echo ERROR& EXIT /b 1
setlocal enabledelayedexpansion
set "Line=!Line:^=^^!"
set "Line=!Line:?=^=!"
set "Line=!Line:(=^(!"
set "Line=!Line:)=^)!"
set "Line=!Line:,=^,!"
set "Line=!Line:;=^;!"
set "Line=!Line:&=^&!"
set "Line=!Line:*:=!"
for /f delims^= %%O in ("!Line!") do (
endlocal
set "Line=%%~O"
)
if defined debug echo ON
for /f tokens^=* %%O in (^"^
%Line%^") do if "%%~nI" neq "%%~O" set "In=%%I" &set "Out=%%~O%%~xI"
if defined out set "out=%out: .=.%"
rem NO execute, only displayed
if defined out ECHO ren "%in%" "%out%"
@echo OFF
exit /b
:: END SUBscript :multiple
:: begin
==:checkCMDline [parentBatch Fullname]
:: setzt eine Variable CMDPause wenn im Batchmodus
:: VAR CMDPause = read CMD-Kontex ;set pause
:: When called from the parent batch program, the Fullname must be passed as a parameter
@echo off
setlocal disabledelayedexpansion
rem CMD-Kontex ?
set "CMDPause=%~f0"
if /i "%~0" equ ":checkCMDline" set "CMDPause=%~f1"
set "CMDPause=%CMDPause:\=\\%"
set "CMDPause=%CMDPause:.=\.%"
setlocal enabledelayedexpansion
for /f delims^= %%i in ("!CMDcmdLine!") do endlocal &set "CMDPin=%%i"
cmd /von /c "echo !CMDPin!" |findstr /irc:"cmd .*\/c \"\"%CMDPause%\" .*\"" ^
/c:"cmd\.exe .*\/c \"\"%CMDPause%\" .*\"" >nul
endlocal
if not errorlevel 1 set "CMDPause=pause &"
if errorlevel 1 set "CMDPause="
if /i "%~0" equ ":checkCMDline" exit /b
:: END checkCMDline
:: begin
==:SetEchoBack
:: Liest ob ECHO ON oder OFF geschalten ist um Variablen zu setzen
:: VAR EchoBack = read and set ECHO ON / OFF
@(
echo>"%temp%\isOn.Ft"
for /f "usebackq tokens=2 delims=()" %%E in (
"%temp%\isOn.FT") do @set "EchoBack=echo %%E &"
del "%temp%\isOn.Ft"
set prompt=$G$S
if /i "%~0" equ ":SetEchoBack" exit /b
)
:: END SetEchoBack
Oh what I still wanted to say: ECHO writes what would be renamed if you delete it.
Phil
Last edited by pieh-ejdsch on 27 Nov 2016 12:08, edited 1 time in total.