batch-file

Batch file tokens ignore empty delimiters

早过忘川 提交于 2020-02-01 07:36:28
问题 I am trying to load a column from a CSV file into a variable. My CSV file contains empty columns so can have ,, which seems to be ignored by the following: FOR /F "tokens=3 delims=," %%a in (csvfile.csv) do ( set date=%%a echo %%a ) So if file csvfile.csv contains fred,wilma,tony, john, greg, wilber, blake chris,,steve,deon,bryan,mark,anthony I would like the result: tony steve But I get: tony deon If I put a white space in the empty column this does work as expected. How do I set delims so

Batch file tokens ignore empty delimiters

吃可爱长大的小学妹 提交于 2020-02-01 07:36:04
问题 I am trying to load a column from a CSV file into a variable. My CSV file contains empty columns so can have ,, which seems to be ignored by the following: FOR /F "tokens=3 delims=," %%a in (csvfile.csv) do ( set date=%%a echo %%a ) So if file csvfile.csv contains fred,wilma,tony, john, greg, wilber, blake chris,,steve,deon,bryan,mark,anthony I would like the result: tony steve But I get: tony deon If I put a white space in the empty column this does work as expected. How do I set delims so

How to decrypt multiple pdf files using qpdf?

£可爱£侵袭症+ 提交于 2020-02-01 04:11:05
问题 I have some n number of pdf files which are SECURED( i.e not password secured, but owner secured). I was able to decrypt single pdf at a time using _ "qpdf --decrypt Input.pdf Output.pdf" from Cmd Promt in Windows. can you help me to do the same with multiple pdf's using batch file or from cmd prompt. 回答1: @echo off setlocal enableextensions disabledelayedexpansion if not exist output\ md output for %%a in (*.pdf) do qpdf --decrypt "%%~fa" "output\%%~nxa" Create an output folder under current

Difference between xcopy and robocopy

ε祈祈猫儿з 提交于 2020-01-30 14:12:09
问题 I'm kind of new to batch scripting. As a newbie I find both both of them useful while scripting What are the key differences between xcopy and robocopy? 回答1: Robocopy replaces XCopy in the newer versions of windows Uses Mirroring, XCopy does not Has a /RH option to allow a set time for the copy to run Has a /MON:n option to check differences in files Copies over more file attributes than XCopy Yes i agree with Mark Setchell, They are both crap. (brought to you by Microsoft) UPDATE: XCopy

Command line .cmd/.bat script, how to get directory of running script

前提是你 提交于 2020-01-30 14:04:25
问题 How can you get the directory of the script that was run and use it within the .cmd file? 回答1: Raymond Chen has a few ideas: https://devblogs.microsoft.com/oldnewthing/20050128-00/?p=36573 Quoted here in full because MSDN archives tend to be somewhat unreliable: The easy way is to use the %CD% pseudo-variable. It expands to the current working directory. set OLDDIR=%CD% .. do stuff .. chdir /d %OLDDIR% &rem restore current directory (Of course, directory save/restore could more easily have

Variables are not behaving as expected

不打扰是莪最后的温柔 提交于 2020-01-30 12:55:26
问题 I've been wrestling trying to get the syntax right on this batch file and I cannot figure out why some things aren't working. The variable i is not getting incremented each time I do it. Concatenation on strc doesn't seem to concatenate. Here is my code: set i=0 set "strc=concat:" for %%f in (*.mp4) do ( set /a i+=1 set "str=intermediate%i%.ts" set strc="%strc% %str%|" ffmpeg -i "%%f" -c copy -bsf:v h264_mp4toannexb -f mpegts "%str%" ) set strc="%strc:-1%" ffmpeg -i "%strc%" -c copy -bsf:a

Variables are not behaving as expected

落爺英雄遲暮 提交于 2020-01-30 12:54:39
问题 I've been wrestling trying to get the syntax right on this batch file and I cannot figure out why some things aren't working. The variable i is not getting incremented each time I do it. Concatenation on strc doesn't seem to concatenate. Here is my code: set i=0 set "strc=concat:" for %%f in (*.mp4) do ( set /a i+=1 set "str=intermediate%i%.ts" set strc="%strc% %str%|" ffmpeg -i "%%f" -c copy -bsf:v h264_mp4toannexb -f mpegts "%str%" ) set strc="%strc:-1%" ffmpeg -i "%strc%" -c copy -bsf:a

Problem with nested FOR-Loop and IF-Condition

混江龙づ霸主 提交于 2020-01-30 11:17:43
问题 I have some lines of text. Then I have a list with test-words. I like to look up each line of the text and check if one of the test-words appears in it. Beforehand this works well with a commands like these: IF not "!stringToTest:%searchstring%=!"=="!stringToTest!" However, now this seems to be more complicated as I have nested Loops? I try to create a little MWE for my problem: @echo off setlocal enabledelayedexpansion set /a counterPC=0 set "listPC=Win10,Motherboard,USB-Port,Core" FOR %%G

How do I escape Ampersand (&) from current working directory %~dp0 in batch file

依然范特西╮ 提交于 2020-01-30 09:35:06
问题 I usually get the current working directory by giving the batch command %~dp0 for combine multiple csv files. But I encountered ampersand (&) symbol while getting current working directories which makes batch file broke after the '&' saying the path after & is not recognized as an internal or external command. Can any of you guys please help me in modifying my below script in identifying & and replacing it with ^& (as this can escape the & and run the batch file). Any of your suggestions is

Remove the Google Chrome pinned icon on the taskbar

我的梦境 提交于 2020-01-30 08:30:28
问题 I want to remove the Google Chrome pinned icon on the taskbar. The uninstall does NOT remove the icon. I modified code to remove just the Google Chrome.lnk. What I want to do (knowing about VBS) is to loop through all the user folders not just the current user which is I believe defined as strCurrentUserAppData . The other desire I would like to do with this code is to use it with SCCM to do a clean install of Chrome. I installed the x64 version and need to replace it with the x86 version.