SET/P "=TEXT" <nul | CLIP
Search found 89 matches
- 23 Aug 2023 01:07
- Forum: DOS Batch Forum
- Topic: avoid trailing space when piping to CLIP [SOLVED]
- Replies: 6
- Views: 5600
Re: avoid trailing space when piping to CLIP
Use double quotes in the set command:
- 09 Aug 2023 08:48
- Forum: DOS Batch Forum
- Topic: Putting BAT on Taskbar or inserting it to Tray
- Replies: 4
- Views: 8618
Re: Putting BAT on Taskbar or inserting it to Tray
One way that seems to work: Go to the location of your batchfile in explorer. Right click on your batchfile: click Create Shortcut. Now you have a shortcut with the correct batchfile and starting directory. The only problem is this is implicit started by the cmd.exe. Next step is make this start exp...
- 31 Jul 2023 17:12
- Forum: DOS Batch Forum
- Topic: Timeout with GUI adjustments breaks its design after first second passes
- Replies: 16
- Views: 65037
Re: Timeout with GUI adjustments breaks its design after first second passes
Use a for/L loop to do the countdown, and in the loop do the echoing for your message followed by an invisible timeout /T 1. And with invisible I mean suppress the output of timeout with >nul.
- 23 Jul 2023 08:33
- Forum: DOS Batch Forum
- Topic: Does "endlocal" close all instances of "setlocal"?
- Replies: 2
- Views: 1863
Re: Does "endlocal" close all instances of "setlocal"?
Just add a few lines to your script and the answer is obvious. Try the script below. setlocal enabledelayedexpansion enableextensions set name1=1 setlocal disabledelayedexpansion enableextensions set name2=2 setlocal enabledelayedexpansion enableextensions set name3=3 set name endlocal set name endl...
- 21 Jul 2023 03:22
- Forum: DOS Batch Forum
- Topic: Clearing an array is done as a partial match? Why?
- Replies: 1
- Views: 1210
Re: Clearing an array is done as a partial match? Why?
Set Var reports all variables starting with Var
Try add a closing "]" in the clear routine.
Try add a closing "]" in the clear routine.
Code: Select all
REM Clear Array
FOR /F "delims==" %%1 IN ('SET STR[%%A]') DO SET "%%1="
- 19 Jul 2023 13:23
- Forum: DOS Batch Forum
- Topic: Finding cause of "The filename, directory name, or volume label syntax is incorrect" error when deleting files [SOLVED]
- Replies: 11
- Views: 3618
Re: Finding cause of "The filename, directory name, or volume label syntax is incorrect" error when deleting files blunt
Such a small script and you seem to fundamentally unable to interpreted what that script is doing. There is nothing fake about the error message you get and your script is doing exactly what you programmed, although not what you intended it to do. You intend to process a list of valid drive-identifi...
- 16 Jul 2023 14:00
- Forum: DOS Batch Forum
- Topic: Finding cause of "The filename, directory name, or volume label syntax is incorrect" error when deleting files [SOLVED]
- Replies: 11
- Views: 3618
Re: Finding cause of "The filename, directory name, or volume label syntax is incorrect" error when deleting files blunt
You still do not see what happens?
Drive Z: is completely processed. The error happens after that!
So your script tries to process 'something' after all the drives are processed and that is causing the error you are getting.
Drive Z: is completely processed. The error happens after that!
So your script tries to process 'something' after all the drives are processed and that is causing the error you are getting.
- 15 Jul 2023 08:12
- Forum: DOS Batch Forum
- Topic: Finding cause of "The filename, directory name, or volume label syntax is incorrect" error when deleting files [SOLVED]
- Replies: 11
- Views: 3618
Re: Finding cause of "The filename, directory name, or volume label syntax is incorrect" error when deleting files blunt
Ok, next hint, try the following script, that should make it clear where your problems originate!
Code: Select all
@echo off
for /F "skip=1" %%D in ('wmic logicaldisk get caption') do (
echo Processing drive: [%%D]
cd /D %%D
dir /AH /S "~$*.xlsm"
del /AH /S /Q ~$*.xlsm
)
pause
- 13 Jul 2023 13:22
- Forum: DOS Batch Forum
- Topic: Finding cause of "The filename, directory name, or volume label syntax is incorrect" error when deleting files [SOLVED]
- Replies: 11
- Views: 3618
Re: Finding cause of "The filename, directory name, or volume label syntax is incorrect" error when deleting files blunt
Try again with echo ON.
This will show you were your code goes wrong!
Hint, there is nothing wrong with the filename or location.
This will show you were your code goes wrong!
Hint, there is nothing wrong with the filename or location.
- 13 Jul 2023 09:11
- Forum: DOS Batch Forum
- Topic: Finding cause of "The filename, directory name, or volume label syntax is incorrect" error when deleting files [SOLVED]
- Replies: 11
- Views: 3618
Re: Finding cause of "The filename, directory name, or volume label syntax is incorrect" error when deleting files blunt
add before the line.
This will show which files are selected to be deleted.
It is probably a file with a space or % or poison character like & or | in the filename.
Code: Select all
dir /AH /S "~$*.xlsm"
Code: Select all
del /AH /S /Q ~$*.xlsm
This will show which files are selected to be deleted.
It is probably a file with a space or % or poison character like & or | in the filename.
- 06 Jul 2023 07:23
- Forum: DOS Batch Forum
- Topic: Breaking PS1 line within BAT file [SOLVED]
- Replies: 5
- Views: 1957
Re: Breaking PS1 line within BAT file
Use the standard line-continuation of cmd using a caret at the end of the line. The following will probably work (untested): powershell.exe -Command "$directories = @('C:\Users\YOUR-USER-NAME\AppData\Roaming\ASCOMP Software\BackUp Maker\logs');^ foreach ($directory in $directories) { Set-Location -P...
- 02 Jul 2023 14:12
- Forum: DOS Batch Forum
- Topic: Inserting comment within a broken line - is it possible? [WORKAROUND]
- Replies: 8
- Views: 2480
Re: Inserting comment within a broken line - is it possible?
Not a real comment but you can hide your comment in a non-existent variable followed by the line-continuation caret. The my comment part must still be valid cmd syntax. @echo on cls dir c:\ ^ %==my comment==% ^ /one pause An other option is to use a null character to hide your comment from cmd. Ever...
- 09 Jun 2023 02:40
- Forum: DOS Batch Forum
- Topic: nested IF statements, best practice (newbie question)
- Replies: 5
- Views: 1949
Re: nested IF statements, best practice (newbie question)
Here is a different approach using a for-loop. rem with the echo messages set "error=" for %%D in ("libiconv2.dll", "libintl3.dll" "libcharset1.dll") do ( if exist "%%D" ( set "%%~nd=y" echo %%D exsists ) ) if not defined libiconv2 (set "Dep_3=y" & set error=6) if not defined libintl3 (set "Dep_4=y"...
- 04 Jun 2023 01:27
- Forum: DOS Batch Forum
- Topic: Batch file to show count of different filetypes in a folder
- Replies: 17
- Views: 18475
Re: Batch file to show count of different filetypes in a folder
This batchfile lists for the files in the current directory the file extensions found and how many files have these extensions. Line by line: The setlocal is needed so the extensions/counters will not be stored in the environment and persist after the batchfile is finished. The dir /b/a-d "%cd%" par...
- 02 Jun 2023 13:41
- Forum: DOS Batch Forum
- Topic: Is there any standard equivalent of a .bashrc script for cmd?
- Replies: 16
- Views: 15209
Re: Is there any standard equivalent of a .bashrc script for cmd?
SystemRoot=C:\WINDOWS So "%SystemRoot%/system32/cmd.exe" becomes "C:\WINDOWS/system32/cmd.exe" what gets executed is md .exe so probably something like this happens command looks like %ComSpec% but with some forward slashes instead of backslashes. ComSpec=C:\WINDOWS\system32\cmd.exe command is inte...