batch-file

Passing Unicode parameters to Windows .bat file when rerunning it

一笑奈何 提交于 2020-07-18 10:41:08
问题 My .bat file looks like this: @echo off CD /D "%~dp0" if [%2]==[] ( set user=%USERNAME% ) else ( set user=%2% ) :getFile if [%1]==[] ( set /p file=Enter file name : ) else ( set file=%~f1 echo File name: %~f1 ) :checkFile for /f "useback tokens=*" %%a in ('%file%') do set file=%%~a if not exist "%file%" ( echo Error: Could not find file: %file% echo. ) :: Check for admin permissions >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" if '%errorlevel%' == '0' (

Copy File's Parent directory path from context menu

坚强是说给别人听的谎言 提交于 2020-07-18 07:44:26
问题 I am learning batch scripting since it's very useful for setting some quick custom context menu options of Windows user's choice to get file and it's parent directory's path. Now I know following command to get the passed argument as file path and copy it to clipboard: cmd /c (echo.|set /p=""%1"") | clip But then why isn't following syntax working as expected when set in Context menu ? cmd /c (echo.|set /p=""%~dp1"") | clip Is it a variable expansion issue ? Please guide as to why it isn't

Move file to trimmed filename location with full name in Batch

亡梦爱人 提交于 2020-07-10 07:35:16
问题 I'm trying to move several similar files into folders based on the filename. The code below works fine but does not work if the base name is more than 5 characters, then it says the directory already exists, and moves the files to the shorter named folder. The idea is to make folders based on a text file, and move it together with pictures wich start with the same name (up to an "_" to that same folder, while the filenames remain intact. The picture names are longer though with varying

How to move files from a source directory to a destination directory with name of first part of file name?

淺唱寂寞╮ 提交于 2020-07-07 12:27:32
问题 I have written the batch file below with the help of others, but I don't have much experience and so this is a bit difficult for me. I'm trying to transfer PDF files from a specific location to individual folders in another location. Each file name is in this format RANSOM-NH_2018-08-07_5485A635.pdf and based on RANSOM-NH_ the batch file should transfer/move the PDF file to it's proper folder named as such RANSOM-NH_Ransom INC . So based on the initial part of the file name, the file should

How to move files from a source directory to a destination directory with name of first part of file name?

风流意气都作罢 提交于 2020-07-07 12:26:20
问题 I have written the batch file below with the help of others, but I don't have much experience and so this is a bit difficult for me. I'm trying to transfer PDF files from a specific location to individual folders in another location. Each file name is in this format RANSOM-NH_2018-08-07_5485A635.pdf and based on RANSOM-NH_ the batch file should transfer/move the PDF file to it's proper folder named as such RANSOM-NH_Ransom INC . So based on the initial part of the file name, the file should

How to move files from a source directory to a destination directory with name of first part of file name?

送分小仙女□ 提交于 2020-07-07 12:26:01
问题 I have written the batch file below with the help of others, but I don't have much experience and so this is a bit difficult for me. I'm trying to transfer PDF files from a specific location to individual folders in another location. Each file name is in this format RANSOM-NH_2018-08-07_5485A635.pdf and based on RANSOM-NH_ the batch file should transfer/move the PDF file to it's proper folder named as such RANSOM-NH_Ransom INC . So based on the initial part of the file name, the file should

joining same name of content and summing the value of each one together using batch script

こ雲淡風輕ζ 提交于 2020-07-07 07:14:18
问题 Years ago @Mofi helped me creating an amazing .bat script to sum values of many contents, also joining it names and making a total sum of them. Please check the old answer about it, focusing at the Mofi´s answer. How to ignore first and third data column on sorting and summing the text using batch file? But I noticed an issue. Values of less than $ 1,00 doesn't sum right. Values of greater than $ 99.999,99 doesn't sum right or are output wrong sometimes. One example: Using this .txt file to

joining same name of content and summing the value of each one together using batch script

ぃ、小莉子 提交于 2020-07-07 07:12:34
问题 Years ago @Mofi helped me creating an amazing .bat script to sum values of many contents, also joining it names and making a total sum of them. Please check the old answer about it, focusing at the Mofi´s answer. How to ignore first and third data column on sorting and summing the text using batch file? But I noticed an issue. Values of less than $ 1,00 doesn't sum right. Values of greater than $ 99.999,99 doesn't sum right or are output wrong sometimes. One example: Using this .txt file to

Getting the exit code of an application started with the “cmd” and “start” commands

Deadly 提交于 2020-07-05 06:46:49
问题 I have a console application. Interaction with this application is done via TCP/IP. I also have a test framework for it, which is basically a collection of BATCH scripts (...not my fault). What this test framework does for each test is basically this: start /min "myapplication.exe" and wait until verification is received that the application is up and running. send commands via TCP/IP to this application, receive its replies, and check if the timings and values agree with whatever is expected

Batch command to change an icon of the currently running window

时光总嘲笑我的痴心妄想 提交于 2020-06-29 04:25:11
问题 In my working environment I can have up to 10 command prompt windows open, each one set up to work in a different context. Having all of them open, I find myself having to switch between several of them to find the right one that I want to work with. I am already setting different foreground and background colors of each window based on some criteria, but it would be much more easier to distinguish between them by having a different colored icon in the taskbar. That way, I would not even have