batch-file

Escaping a batch file echo that starts with a forward slash and question mark

淺唱寂寞╮ 提交于 2020-01-28 00:07:34
问题 Bit of a tricky one. How can I correctly escape the following in a batch file? echo /? display this help text This particular combination of characters is treated as an "ECHO /?" command: C:\Batch>ECHO /? display this help text Displays messages, or turns command-echoing on or off. ECHO [ON | OFF] ECHO [message] Type ECHO without parameters to display the current echo setting. It does not respond to caret (^) escaping, ie. I've tried ^/? /^? and ^/^?. NB: As a workaround, I found that

Windows console width in environment variable

有些话、适合烂在心里 提交于 2020-01-27 08:18:44
问题 How can I get the current width of the windows console in an environment variable within a batch file? 回答1: I like the approach using the built-in mode command in Windows. Try the following batch-file: @echo off for /F "usebackq tokens=2* delims=: " %%W in (`mode con ^| findstr Columns`) do set CONSOLE_WIDTH=%%W echo Console is %CONSOLE_WIDTH% characters wide Note that this will return the size of the console buffer, and not the size of the window (which is scrollable). If you wanted the

Windows console width in environment variable

爱⌒轻易说出口 提交于 2020-01-27 08:17:27
问题 How can I get the current width of the windows console in an environment variable within a batch file? 回答1: I like the approach using the built-in mode command in Windows. Try the following batch-file: @echo off for /F "usebackq tokens=2* delims=: " %%W in (`mode con ^| findstr Columns`) do set CONSOLE_WIDTH=%%W echo Console is %CONSOLE_WIDTH% characters wide Note that this will return the size of the console buffer, and not the size of the window (which is scrollable). If you wanted the

.bat measure file path length and put it in a .txt-file

本小妞迷上赌 提交于 2020-01-25 23:40:25
问题 I'm trying to make a .bat file that will run through all files in a given folder, measure the length of the file+path and if its longer than eg. 50 characters the file and path are written into a .txt-file. I'm pretty much a n00b, so not to advanced, and somewhat well explained ;). im writing into a file with echo %File% > filer.txt Where File should contain the file name and path. Edit: Im sorry, I was perhaps a bit unclear in my description of the task it should preform. What I ment was,

XCOPY Command Date option for copying files

笑着哭i 提交于 2020-01-25 23:19:14
问题 Can someone tell me if there is any way if we don't want to copy the files after the specified date. E.g. if i specify the date 10-MAY-2017 & 11-MAY-2017 and folder has files for 10 & 11 May 2017. So if want only the 10-MAY-2017 files to copied. is there is any way ? 回答1: For the task at hand, robocopy is the easiest way to do it: robocopy D:\Source D:\Destination *.* /S /MINAGE:20170510 Despite the name of switch /MINAGE , not the creation but the last modification date is regarded. In case

Incrementing file version numbers with batch file

杀马特。学长 韩版系。学妹 提交于 2020-01-25 23:01:27
问题 I am trying to do something nearly identical to this: How do I increment a folder name using Windows batch? Essentially, I want to create a batch file to scan through a directory, determine the highest version number, and then create the next one in sequence. So if the directory contains: New folder V1.0 New folder V1.1 New folder V1.3 I want the batch file to add a New folder V1.4. Should be doable. The problem is that the script I found: @echo off setlocal enableDelayedExpansion set

ffmpeg: Output to the same folder as source with recursive input?

非 Y 不嫁゛ 提交于 2020-01-25 21:07:05
问题 I have a lot of gifs I want converted to webms in many sub directories, and I have this script which will do it, but it will output to the directory where the script is located: for /r %%a in ("*.gif") do ffmpeg -i "%%a" -c:v libvpx -crf 12 -b:v 4000k "%%~na.webm" pause I've tried a bunch of things, but I can't figure out how to get the output to land in the same sub directory as the input file so I can maintain the folder structure. Edit: it's a Windows batch file I'm using. 回答1: You are

Task Scheduler is not supporting option “Run with highest Privilege” and “Run weather user is logged on or not”

情到浓时终转凉″ 提交于 2020-01-25 17:23:56
问题 I am trying to schedule Task on Task Scheduler, every thing is working fine unless I tick "Run with Highest privileges" or "Run weather user is logged on or not" As soon as I tick this, scheduler stop triggering my Script. Script- .Bat file using Power Shell command. Can any one figure out what went wrong? Edited- ( Changed file location from drive to network drive) @Echo Off :: SDate=DAYMONTHYEAR FORMAT of Systemdate ::set SDate=%date:~7,2%%date:~4,2%%date:~10,4% ::Variable for folder path

Task Scheduler is not supporting option “Run with highest Privilege” and “Run weather user is logged on or not”

≡放荡痞女 提交于 2020-01-25 17:20:09
问题 I am trying to schedule Task on Task Scheduler, every thing is working fine unless I tick "Run with Highest privileges" or "Run weather user is logged on or not" As soon as I tick this, scheduler stop triggering my Script. Script- .Bat file using Power Shell command. Can any one figure out what went wrong? Edited- ( Changed file location from drive to network drive) @Echo Off :: SDate=DAYMONTHYEAR FORMAT of Systemdate ::set SDate=%date:~7,2%%date:~4,2%%date:~10,4% ::Variable for folder path

cmd insert text into the middle of the file name

萝らか妹 提交于 2020-01-25 15:52:29
问题 I am moving files from one directory to a newly created directory. Currently the script inserts the id variable to the start of the file name for all the file names. I would like to insert the id variable after model name variable in all the file names. How do I do that? I have the following code in my cmd file. @echo off rem set 12d variables set modelname=dr network_ set id=10yr_ mkdir "%modelname%" rem move to new dir created move "%modelname%*.rpt" "%modelname%" rem change working