windows batch file rename

Use REN Command Ren is for rename ren ( where the file is located ) ( the new name ) example ren C:\Users\&username%\Desktop\aaa.txt bbb.txt it will change aaa.txt to bbb.txt Your code will be : ren (file located)AAA_a001.jpg a001.AAA.jpg ren (file located)BBB_a002.jpg a002.BBB.jpg ren (file located)CCC_a003.jpg a003.CCC.jpg and so on IT WILL NOT WORK IF … Read more

Task scheduler cannot open batch file when set to run whether user is logged on or not

I have resolved this problem with help from a contractor who was doing some other work for my institution. In the properties window for the task, on the Action tab, when creating or editing the action that opens the batch file (in my case test.bat), there is the “Program/script:” field and there is also a … Read more

How to split double quoted line into multiple lines in Windows batch file?

I see three possible workarounds. 1) Building the line combining multiple for-parameters. @echo off SETLOCAL EnableDelayedExpansion set “line=” for %%a in (“line1” “line2” “line3” “line4″ ) do set line=!line!%%~a echo !line! Drawback: It drops lines, when there is a ? or * in the text. 2) Leaving the “quote” at the end of each line … Read more

Batch script to find and replace a string in text file within a minute for files up to 12 MB

Give this a shot: @echo off setlocal call :FindReplace “findstr” “replacestr” input.txt exit /b :FindReplace <findstr> <replstr> <file> set tmp=”%temp%\tmp.txt” If not exist %temp%\_.vbs call :MakeReplace for /f “tokens=*” %%a in (‘dir “%3” /s /b /a-d /on’) do ( for /f “usebackq” %%b in (`Findstr /mic:”%~1″ “%%a”`) do ( echo(&Echo Replacing “%~1” with “%~2” in … Read more

Does Windows batch support exception handling?

Windows batch scripting certainly does not have any formal exception handling – hardly surprising considering how primitive the language is. Never in my wildest dreams did I ever think effective exception handling could be hacked up. But then some amazing discoveries were made on a Russian site concerning the behavior of an erroneous GOTO statement … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)