cmd

cmd: save wmic output to variable

断了今生、忘了曾经 提交于 2021-02-04 21:05:34
问题 I am trying to get the timestamp of a file into a variable in a batch file. My batch file, imagetime.bat contains the following: set targetfile=%~1 set targetfile=%targetfile:\=\\% echo %targetfile% for /f "usebackq delims=" %%i in ( `wmic datafile where name^="%targetfile%" get creationdate` ) do ( echo %%i ) echo %timestamp% And I get this output: C:\>imagetime.bat V:\setup.exe C:\>set targetfile=V:\setup.exe C:\>set targetfile=V:\\setup.exe C:\>echo V:\\setup.exe V:\\setup.exe C:\>for /F

cmd: save wmic output to variable

↘锁芯ラ 提交于 2021-02-04 21:05:30
问题 I am trying to get the timestamp of a file into a variable in a batch file. My batch file, imagetime.bat contains the following: set targetfile=%~1 set targetfile=%targetfile:\=\\% echo %targetfile% for /f "usebackq delims=" %%i in ( `wmic datafile where name^="%targetfile%" get creationdate` ) do ( echo %%i ) echo %timestamp% And I get this output: C:\>imagetime.bat V:\setup.exe C:\>set targetfile=V:\setup.exe C:\>set targetfile=V:\\setup.exe C:\>echo V:\\setup.exe V:\\setup.exe C:\>for /F

Delete file with specific extension in batch file

眉间皱痕 提交于 2021-02-04 18:50:37
问题 I would like to recursively delete all files with a specific extension in a batch file. I am aware of the following command: del /s *.ext However, this does on Windows also delete files with other extensions like e.g. .ext1 or .ext2 . The reason for this seems to be that the 8.3 file name of such a file ends with .ext and therefore also the files with longer extensions are matched. I am looking for a replacement to the command above that recursively deletes all files with .ext extension but

C# publishing an .exe and sending params to it using cmd

你离开我真会死。 提交于 2021-02-04 15:43:27
问题 i am pretty sure this is basic but i just dont success to do this i am trying to create a console application that would do ABC by getting few arguments for start i am trying to run something as simple as that static void Main(string[] args) { foreach (var s in args) { Console.WriteLine(s); } Console.ReadLine(); } when i publish it it comes at as a 'clickonce' project like NAME.application instead of NAME.exe also , when i am trying to go execute it with XYZ parms like trying in same folder

C# publishing an .exe and sending params to it using cmd

社会主义新天地 提交于 2021-02-04 15:42:56
问题 i am pretty sure this is basic but i just dont success to do this i am trying to create a console application that would do ABC by getting few arguments for start i am trying to run something as simple as that static void Main(string[] args) { foreach (var s in args) { Console.WriteLine(s); } Console.ReadLine(); } when i publish it it comes at as a 'clickonce' project like NAME.application instead of NAME.exe also , when i am trying to go execute it with XYZ parms like trying in same folder

Get Parent directory of a specific path in batch script

孤者浪人 提交于 2021-02-04 11:33:31
问题 Hi I have full file path in a variable of batch file. How to get its first and second level parent directory path? set path=C:\SecondParent\FirstParent\testfile.ini 回答1: do not use variable PATH for this. %PATH% is a built-in variable used by the command prompt. @echo off set "_path=C:\SecondParent\FirstParent\testfile.ini" for %%a in ("%_path%") do set "p_dir=%%~dpa" echo %p_dir% for %%a in (%p_dir:~0,-1%) do set "p2_dir=%%~dpa" echo %p2_dir% 回答2: As npocmaka correctly suggests, pick a

Batch copying a source file to certain subdirectories, with copy names based on files within? [duplicate]

十年热恋 提交于 2021-01-29 20:28:47
问题 This question already has an answer here : Variables are not behaving as expected (1 answer) Closed last month . As it says in the title, I have a need to copy a source txt file to any number of tga files that reside within a certain set of subfolders in the directory, where the copies of the txt file have names matching the tga files there. Let's say I have a folder structure looking like this: destination1/aaa.tga destination1/bbb.tga destination2/aaa.tga otherfolder/ccc.tga ddd.tga copyme

Windows CMD FINDSTR STRING AND COPY FILE

半城伤御伤魂 提交于 2021-01-29 19:29:55
问题 I have a folder with subfolders include txt and pdf files. There is a Pdf file for each txt file which has nearly same name. For example; for each ABC_R10.txt --> there is a ABC).pdf file. In Windows 10, with a batch file, I want to search specific string in a .txt file with FINDSTR command, and copy files, which contain my string, into current folder. I achieved proper code until this point. CLS @ECHO OFF ECHO FIND BUKUM findstr /m /s /i /p /c:"BUKUM" *.txt > logfile.xls for /f "delims=" %%a

Batch: Taskkill timeout without waiting for timer

我怕爱的太早我们不能终老 提交于 2021-01-29 17:53:30
问题 I'm writing a batch script which runs a few programs. As each program finishes what it's doing it waits for either the user to close it out, moving on to the next, or being closed by taskkill after a timeout of so many seconds. If I consider the main script as MAIN, the program as TASK and the timer as KILLER. The MAIN starts the TASK and KILLER at (about) the same time. TASK does what it's supposed to and KILLER waits 600 seconds before killing TASK. However if TASK were closed by the user

Delete files based on MD5 hash

感情迁移 提交于 2021-01-29 14:33:05
问题 Using Windows command line (not powershell), I want to hash all files within the directory and then remove files that match a particular hash set contained within a text file. I've considered using md5deep, but I'm unsure if the output of matched files can then be redirected into a delete command. Any help gratefully received, thank you! To add some detail; the files are in a directory called 'images' md5deep.exe -r -b -x irrelevant_hashes.txt c:\images This gives me a list of the files that