batch-file

How to use “ren” or “rename” to truncate the file name until underscored?

。_饼干妹妹 提交于 2020-05-17 06:00:55
问题 I have some file names as below saved in C:\aaa\temp Before: 92485345_A0027777882244.zip 87493354_A0027684085444.zip 87111901_A0027871905777.zip some fixed rule in the file name: I need to delete the characters until the underscore "_" The name after underscore always begins with A0027 Can someone please teach me how to write a script to batch rename them as below: After: A0027777882244.zip A0027684085444.zip A0027871905777.zip 回答1: If the number of characters in front of the underscore _ is

[Batch]Looping until a key is pressed

那年仲夏 提交于 2020-05-17 03:30:07
问题 what I want to do here is loop until "x" is pressed. I am aware of CHOICE with the /T option. But CHOICE has too long of a timeout for a animation that I want to play. Here is a example : @echo off cls set frame=2 :loop cls type [%frame%].txt [Here is where it would test for the keystroke.If keystroke "x" is detected,goto MENU. If not pressed within a quick second,continue.] set /a frame=%frame%+1 goto loop note: The frames are for a animation,so do keep in mind that the timeout must be

Delete extensionless files which names end with '_C' string [duplicate]

半城伤御伤魂 提交于 2020-05-15 19:42:04
问题 This question already has an answer here : How to delete files end with a substring and older than N days (1 answer) Closed 3 months ago . I have a batch code which cleans files which are older than 15 days. But I want to only delete files that end with '_C' and they have no extension. Here is my code: SET mypath=%cd%/downloads ForFiles /p %mypath% /d -15 /c "cmd /c For /R %%A in (*_C.*) Do (del /q @fname) Here are my files: File Name: ---------Date: A_C_123_C ------ 18.02.2019 A_C_456_C ----

Using a batch file to start pm2 when windows starts?

人走茶凉 提交于 2020-05-15 13:27:41
问题 I can't get pm2 to start my apps on Windows start. I'm running Windows Server 2012 R2 Standard and pm2 2.4.2 . I have a pm2 process file in JSON format which I use to start all my apps. c:\pm2\process.json { "apps": [ { "name" : "my-app", "script" : "c:\\node\\myapp\index.js" } ] } I have a batch file which uses the JSON file: c:\pm2\pm2-startup.bat @echo off set HOMEDRIVE=C: set PM2_HOME=C:\etc\.pm2 setx /M PM2_HOME C:\etc\.pm2 cd C:\pm2 & pm2 start process.json I have a Windows task

Using a batch file to start pm2 when windows starts?

≡放荡痞女 提交于 2020-05-15 13:25:25
问题 I can't get pm2 to start my apps on Windows start. I'm running Windows Server 2012 R2 Standard and pm2 2.4.2 . I have a pm2 process file in JSON format which I use to start all my apps. c:\pm2\process.json { "apps": [ { "name" : "my-app", "script" : "c:\\node\\myapp\index.js" } ] } I have a batch file which uses the JSON file: c:\pm2\pm2-startup.bat @echo off set HOMEDRIVE=C: set PM2_HOME=C:\etc\.pm2 setx /M PM2_HOME C:\etc\.pm2 cd C:\pm2 & pm2 start process.json I have a Windows task

Using a batch file to start pm2 when windows starts?

微笑、不失礼 提交于 2020-05-15 13:25:11
问题 I can't get pm2 to start my apps on Windows start. I'm running Windows Server 2012 R2 Standard and pm2 2.4.2 . I have a pm2 process file in JSON format which I use to start all my apps. c:\pm2\process.json { "apps": [ { "name" : "my-app", "script" : "c:\\node\\myapp\index.js" } ] } I have a batch file which uses the JSON file: c:\pm2\pm2-startup.bat @echo off set HOMEDRIVE=C: set PM2_HOME=C:\etc\.pm2 setx /M PM2_HOME C:\etc\.pm2 cd C:\pm2 & pm2 start process.json I have a Windows task

batch: launch pipenv shell, then run command in the virtual environment

我只是一个虾纸丫 提交于 2020-05-15 08:47:07
问题 Here is a batch script: Z: cd Z:\different_directory pipenv shell cd ..\another_directory :End cmd /k What happens here is that the pipenv shell gets launched, but the virtual environment does not cd. Instead, once I exit the pipenv, it then runs the cd command. Is it possible to run a command from inside the pipenv using this batch script? 回答1: You can use pipenv run instead of pipenv shell to directly run a python command or a batch script. You won't be able to run pipenv run cd ../another

What could be the reason for batch file with just REG ADD command looping endless?

六眼飞鱼酱① 提交于 2020-05-15 07:42:47
问题 I have below line in my batch file test.bat which adds an entry to Windows registry: @echo off REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Server" /v DisplayName /t REG_SZ /d Server /f The command is working when I run the same line from within a command prompt window. But it results in an infinite loop when I put this line into batch file test.bat and run the batch file on Windows 7. What could be the reason for this unexpected batch file processing? 回答1: It is

What could be the reason for batch file with just REG ADD command looping endless?

好久不见. 提交于 2020-05-15 07:42:42
问题 I have below line in my batch file test.bat which adds an entry to Windows registry: @echo off REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Server" /v DisplayName /t REG_SZ /d Server /f The command is working when I run the same line from within a command prompt window. But it results in an infinite loop when I put this line into batch file test.bat and run the batch file on Windows 7. What could be the reason for this unexpected batch file processing? 回答1: It is

Command Prompt/Batch - rename multiple files with sequential numbering

放肆的年华 提交于 2020-05-14 22:04:06
问题 Lets say I have multiple files filename.a.txt filename.b.txt filename.c.txt I want to run a batch file that targets all .txt files and rename them to whatever I have set into my custom %filename% var + give them numbers so it would end up into something like: filename.1.txt filename.2.txt filename.3.txt So far I have wrote this: set filename=FileTitle for /r %%i in (*.txt) do call ren %%i %filename%.txt And it works, but problem is that it just picks up first .txt file and gives it the