batch-file

Parse file name using batch automation

我们两清 提交于 2020-01-17 01:17:28
问题 This maybe simple enough, but I am not that of an expert to computer languages. I've been stuck searching for a solution for almost 3 hours on the internet. Assuming all my mp3 files are titled with "Name of Artist - Title of Song.mp3" I would want it to output into a txt file that contants: Artist: Name of Artist Song: Title of Song How do I parse the file name into two parts separated with a hyphen? I've been trying to do some sort of automation with batch files for archiving purposes and

Batch file with current date

别等时光非礼了梦想. 提交于 2020-01-17 00:07:29
问题 All, need a hlep in scripting in with batch file. I am very much new to scripting. I have an etl job which creates a file in a folder named as FINANCE20141011.txt. I need to create a batch file which will find current days file which is FINANCE20141011.txt (current date is 11/10/2014 and send the file to sftp server. There would be multiple file in the folder such as, FINANCE20141009.txt, FINANCE20141008.txt. But the script should pull up the current days file. Any help. Thanks. 回答1: @Echo

Executing batch file from runnable jar gives path not found error

☆樱花仙子☆ 提交于 2020-01-16 20:47:21
问题 I am executing a batch file from java program. When I execute from eclipse it works fine but when I make it a runnable jar it is not able to find the path of the batch file I kept the batch file as a resource in the source directory. When I print the path of the resource using Class.getResource("/resource/mybat.bat") it gives the path correctly as resources/mybat.bat (jar creation option : package required library into generated jar) file:/C:/Users/aasha.medhi/Desktop/myjar.jar!/resources

rename file with “previous weekday”

陌路散爱 提交于 2020-01-16 19:50:10
问题 Is it possible for a batch file to rename all files in a directory by appending the date of previous weekday to the end of the filename? for example, if i ran it on Monday 2/25/12, it would add "_022213" to the end of the filenames in the directory. Thanks... 回答1: Here you go. @echo off setlocal enabledelayedexpansion echo wd = Weekday^(Date^(^), vbSunday^)>yesterday.vbs echo if wd ^< 3 then dif = -1 - wd else dif = -1 >>yesterday.vbs echo d = dateadd^("d", dif, Date^(^)^)>>yesterday.vbs echo

Directory traversal and file selection with .bat

ぐ巨炮叔叔 提交于 2020-01-16 19:49:13
问题 I am trying to write a .bat file that allows me to traverse through directories (up or down) and let me select a file from the current directory, passing that filename out at the end of the routine. Ideally, it would handle if it is at the root of a drive (i.e. C:) or that there are no more sub directories. (If there are more elegant ways of doing what I am asking, please feel free to suggest them!) @echo off setlocal enabledelayedexpansion set FVAR= :start ::---------------------------------

Directory traversal and file selection with .bat

天大地大妈咪最大 提交于 2020-01-16 19:48:12
问题 I am trying to write a .bat file that allows me to traverse through directories (up or down) and let me select a file from the current directory, passing that filename out at the end of the routine. Ideally, it would handle if it is at the root of a drive (i.e. C:) or that there are no more sub directories. (If there are more elegant ways of doing what I am asking, please feel free to suggest them!) @echo off setlocal enabledelayedexpansion set FVAR= :start ::---------------------------------

Detecting batch IP conflict

穿精又带淫゛_ 提交于 2020-01-16 19:05:28
问题 How would you detect an IP conflict? I am trying to implement a fail-over of two systems. Let us assume they take the IPs X.X.X.1 and X.X.X.2 (A and B for convenience), with A as the primary server and B as the back-up. Both A and B will continuously ping X.X.X.1. Should A ever go down, B will detect "request timed out", and convert itself to X.X.X.1 using the following command: netsh int ipv4 set address name="Local Area Connection" source=static address=X.X.X.1 mask=255.255.255.0 gateway

shell:Common Startup as a parameter to XCOPY

冷暖自知 提交于 2020-01-16 19:03:07
问题 I have a simple batch script that copies a file to the startup folder, but it appears that I can't use shell:Common Startup as a parameter to xcopy. I have tried this xcopy hurrdurr.exe "shell:Common Startup" and many other variations, and they don't work. As an aside, if this did work, "hurrdurr.exe" would run on every startup right, assuming I got clearance via uac to do the xcopy operation? Would using a environment variable be better? The os in question is Windows XP and proceeding. 回答1:

shell:Common Startup as a parameter to XCOPY

浪子不回头ぞ 提交于 2020-01-16 19:03:05
问题 I have a simple batch script that copies a file to the startup folder, but it appears that I can't use shell:Common Startup as a parameter to xcopy. I have tried this xcopy hurrdurr.exe "shell:Common Startup" and many other variations, and they don't work. As an aside, if this did work, "hurrdurr.exe" would run on every startup right, assuming I got clearance via uac to do the xcopy operation? Would using a environment variable be better? The os in question is Windows XP and proceeding. 回答1:

is there a way to pipe STDERR and STDOUT to different programs?

╄→尐↘猪︶ㄣ 提交于 2020-01-16 19:01:09
问题 For example I need to set two tee commands in such way that one will be reading from STDOUT and second from STDERR and both redirecting the console output to different files. Is such thing possible in windows batch files ? I know about how to redirect output to file but in this case it won't be displayed on screen or how to combine both streams but how about piping both independently ? 回答1: You may process STDOUT and STDERR with separate programs via the next trick: (test | findstr /N /A:2A "