REN command with wildcard
I have a batch file, that has been working properly, which renames files in bulk. Example input:
The batch file being executed has:
ren C:\Test\NW\Residents_*.csv NorthWest_*.txt ren C:\Test\NE\Residents_*.csv NorthEast_*.txt
and the output, as expected:
Where it doesn't seem to work is when I have an input file:
and use the same command:
ren C:\Test\CAN\Residents_*.csv Canada_*.txt
the output is:
while I would expect the output to be:
In my searching online, I haven't been able to find an explanation to this particular problem. After trying variations of input file names and commands, I believe it has something to do with the length of the file names. Can someone explain why this is happening?
See also questions close to this topic
Hiding taskbar Delphi 2010, need to run program twice
I have a small utility in Delphi 2010, that toggles Windows taskbar. Off is meant to be completely gone, so it will not even pop up if the mouse touches the screen edge. for this, I need to do two thing - Set the taskbar to auto hide, and also hide the taskbar window.
This is how I am trying to do the hiding in console:
uses SysUtils, ShellAPI, Windows; var ABData: TAppBarData; begin ABData.cbSize := sizeof(TAppBarData); ABData.hWnd := FindWindow('SHELL_TRAYWND', nil); ABData.uEdge := ABE_BOTTOM; // Perform AutoHide ON ABData.lParam := lParam(ABS_AUTOHIDE); SHAppBarMessage(ABM_SETSTATE, ABData); // Perfom hide Taskbar ShowWindow(ABData.hWnd, SW_HIDE); end.
For some reason, I need to run this twice if I want to completely hide the taskbar. First run activates Taskbar auto-hide. Only after second run will the window be completely hidden.
To restore the taskbar, I just need to run the program once. It is identical, except:
ABData.lParam := lParam(ABS_ALWAYSONTOP); ShowWindow(ABData.hWnd, SW_SHOW);
I cannot see any logic what would explain the problem, so suspect it must have something to do with ShellAPI.
Find a keyword occurred today using Batch
I need to find All the ORA Errors in my log.txt file that has occurred today using batch program. I am not good with Batch so not able to add date time filter with my code below.
@echo off findstr /m "ORA-" Alert.txt if %errorlevel%==0 ( echo There is an ORA Error in Alert File! )
Errors in file:
2019-10-14T00:43:40.497493+01:00 Errors in file C:\R2DATABASE\PRODUCT\12.2.0\diag\rdbms\r2\r2\trace\r2_j000_11628.trc: ORA-12012: error on auto execute of job "R2"."R3NOTIFICATION_160328336632" ORA-06550: line 1, column 763: PLS-00201: identifier 'R3NOTIFICATION_PKG.GENERATENOTIFICATIONFORR3' must be declared ORA-06550: line 1, column 763: PL/SQL: Statement ignored 2019-10-14T00:43:42.029005+01:00 Errors in file C:\R2DATABASE\PRODUCT\12.2.0\diag\rdbms\r2\r2\trace\r2_j001_2524.trc: ORA-12012: error on auto execute of job "R2"."R3NOTIFICATION_160328336632" ORA-06550: line 1, column 763: PLS-00201: identifier 'R3NOTIFICATION_PKG.GENERATENOTIFICATIONFORR3' must be declared ORA-06550: line 1, column 763: PL/SQL: Statement ignored
Date time format -
How do I start an Appium server in C# with a custom chromedriver?
The android emulator i'm using has a new version of Chrome on it (74). Appium currently doesn't seem to support that high yet and fails.
Got around this by using the latest driver from google and starting an appium server by the terminal pointing specifically to my exe
appium --chromedriver-executable [path]
However, i'd like to be able to spin up an appium server at the start of my tests via something like:
_appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build(); _appiumLocalService.Start();
Is it possible to use a custom chromedriver? If so, how would I go about doing this?
Any help appreciated! Thanks in advance Rye
.bat file execution PreBuild Event in Visual Studio - set /a
I have a batch file executing in the prebuild event of Visual Studio 2019.
for /f "tokens=2" %%i in ('svn info -rHEAD https://repositoryURL^|find "Revision"') do ( echo %%i set /a "b=%%i+1" echo %a% powershell -Command "(gc c:\PathToFile\MainWindow.xaml) -replace 'x:Name=\"Lbl_Version\" Content=\"Revision: %%i\"', 'x:Name=\"Lbl_Version\" Content=\"Revision: %b%\"' | Out-File -encoding UTF8 c:\PathToFile\MainWindow.xaml" )
&&i = 17 at the moment.
This works beautifully if I execute the batch file from cmd. However when executed via Visual Studio, the set /a command seems to return empty. (The String gets replaced with an empty "Revision: " instead of "Revision: 18")
How can I get arround that issue? I don't understand the problem since it works when executed via cmd.
Batch File: "Environment Variable Not Defined" on a path
I have the following in a batch file
for /f "delims=" %%a in ("C:\Program Files (x86)\Wowza\creds.txt") do set %%a net use J: https://csv/dav %p% /user:%u% /persistent:yes
I get an error:
Environment variable C:\Program Files (x86)\Wowza\creds.txt not defined
What do I need to resolve this?
Secondly, it works for all colleagues apart from one. Same laptop make, model and build. I used my details and it failed on his but worked on mine.
What fails is that it asks for the credentials to map the drive instead of taking them from the file
Wait for another batch file to finish the process and process another batch file
Is it possible to wait first for the first batch file to process and then process another batch file? if i run multiple batch file at the same time i got an error "Another instance of the application is already running. Please close the application dialog before using any other program." when calling the program.exe multiple times at the same time.
This is what i tried
@echo off START /Wait cmd.exe /K "C:\Users\Folder\Pictures\batchFile\Encrypt\encrypt.bat"
and here's the command of the encrypt file to encrypt the pdf file:
"C:\Program Files (x86)\Folder\Program.exe" PROTECT "C:\Users\Folder\Pictures\test1.pdf" /OUTPUT "C:\Users\Folder\Pictures\d"
Any idea how to achieve this?
Create a batch file for deploying
1. hg st 2. hg pull -b "Branch Name" 3. hg merge "branch name" 4. hg ci -m "merge Branch Name and Details" -u username 5. hg summary to check what is the update which has happened
want to create a batch file and use the powershell to use, my only concern is, if conflict happens, the batch should abort on step 4 and i SHOULD SOLVE THE conflicts and commit myself then by running extra command which is step 4
manim example_scenes.py won't run
I am using this video to download and install manim on Windows 10. Whenever I try to run this code, it fails.
python -m manim example_scenes.py SquareToCircle -pl
cmd throws a big error at my face. It last line is : Original error was: DLL load failed: The specified module could not be found.
What could be the problem and how can I prevent and/or solve it. Thanks
Move and Rename files using Python
I have .xls files in a directory that i need to move to another directory and renamed. Those files are updated monthly and will have a different name each month. For instance the current name is Geocortex Applications - Asset Capture - Sessions By Visitor Type (10_01_2018 - 10_06_2019).csv and next month it will be Geocortex Applications - Asset Capture - Sessions By Visitor Type (10_01_2018 - 11_06_2019).csv There are several of these files each with different names between the - - but the formatting is the same, see the image below.
Each month i need those files moved to another folder and given the name that is between the - -. For instance this one would need to be renamed 'Asset Capture.xls'.
My python experience is limited...so far i've only used python within ESRI products using Arcpy. Any help that can be given is greatly appreciated.
below is what i've done. I can move a rename a single file but i need it to cycle through all xls and rename with the name between the - - in the file name.
import shutil import os os.chdir(r'C:\Users\learly\Downloads') renFolder= (r'C:\Users\learly\Downloads\renamed') oldname = 'Geocortex Applications - Asset Capture - Sessions By Visitor Type (10_01_2018 - 10_06_2019).csv' newname= 'renTest.csv' shutil.move(oldname, renFolder+'/'+newname)
Adding 2nd file extension to file with certain prefix
I have following files in bulk to modify
xxx.002etc. by adding
.txtat the end of the file name. In order to do this I am using following command:
rename XXXX*.* *?.txt
However it inserts
.txttwice instead of once.
How to rename multiple files at once and replace specific characters without affecting other characters
I want to replace the first two numbers on these 98 files that looks like this
10 10HZ.mp3 11 11HZ.mp3 12 12HZ.mp3
with "Bass Mekanik - " and make it look like this
Bass Mekanik - 10HZ.mp3 Bass Mekanik - 11HZ.mp3 Bass Mekanik - 12HZ.mp3
I've tried a lot of different combinations on CMD like this
*rename "?? ????.mp3" "Bass Mekanik - ????.mp3"
But nothing works. I want to keep the last 4 characters on every file.
Also in the near future I will need to add "Bass Mekanik - " in front of every file (not on these files, other files that have a lot of other characters) without changing anything else. So far I learned how to remove the first 2 characters using
*rename "?? ????.mp3" "// ????.mp3"
Then I tried adding "Bass Mekanik" but it gives an error "A duplicate file name exists, or the file cannot be found." I hope this is possible ...