[Solved] Batch file for moving file to not yet exist folder [closed]

Get the total count of files to move, iterate files and count, calculate the rest and check if uneven. :: Q:\Test\2018\12\14\SO_53784108.cmd @Echo off & SetLocal EnableDelayedExpansion set “Base=A:\PHOTOS” PushD “%Base%” || (Echo can’t find Base:%Base% &Pause&Goto :Eof) :: get Total files For /f %%A in (‘dir /B *.png ^|find /c “.png”‘) Do set “Total=%%%A” Set … Read more

[Solved] Environment variable set in batch file cannot be accessed in the C code compiled by the file [closed]

Wild-assed guess, because you don’t even show a single line of C code: getenv(TEST_VAR) should be getenv(“TEST_VAR”). PS: To avoid downvotes for your next question (and possibly unhelpful answers like mine), please read http://www.catb.org/esr/faqs/smart-questions.html explaining the art of asking smart questions. 2 solved Environment variable set in batch file cannot be accessed in the C … Read more

[Solved] Delete specific subfolder under unknown folders from anywhere

I created a short powershell solution using this- $targetName=”ss s”; foreach ($file in Get-Childitem “G:\Project\Projects\” ) { $fname=$file.name; if (Test-Path “G:\Project\Projects\$fname\$targetName\”) { $shell = new-object -comobject “Shell.Application” $item = $shell.Namespace(0).ParseName(“G:\Project\Projects\$fname\$targetName”) $item.InvokeVerb(“delete”) } } This powershell script sends that folder to recycle bin after confirmation popup. (this won’t send any file named ‘ss s’) this seems … Read more

[Solved] batch script delete .ost bigger than 50 GB

Ok, I found the solution: WMIC to rescue!!!! Do a wmic query and put into a variable: for /f “tokens=2 delims==” %%f in (‘wmic datafile where “path=”\\Users\\%username%\\AppData\\Local\\Microsoft\\Outlook\\” and Extension=’ost’ and FileSize>’48318382080′” get Name /value ^| find “=”‘) do set “file=%%f” solved batch script delete .ost bigger than 50 GB

[Solved] Having trouble getting a list of users profiles [closed]

You’ll want to query WMI for Win32_UserProfile instances – each profile will be linked to the security identifier of the user owning the profile, which can in turn be translated to an account object with the user name: Get-CimInstance win32_userprofile |ForEach-Object { # Convert SID string to SecurityIdentifier object $SID = $_.SID -as [System.Security.Principal.SecurityIdentifier] try … Read more

[Solved] How to : Skip the Header record from one .csv and Copy the Records to another csv file using command prompt or batch [closed]

Except the way Compo suggested (using more with +1 which will exclude the first line), you can use a for /F loop: @echo off for /F “skip=1 delims=” %%A IN (file.csv) do (echo %%A)>>file1.csv which, with the option skip=1 will skip the first line. Another way would be to loop through the output of more … Read more

[Solved] Continuously check a file modified or not using batch file [closed]

My final Code. Thanks for your supports. @echo off setlocal enableextensions disabledelayedexpansion for /f “tokens=2 delims==” %%a in (‘wmic OS Get localdatetime /value’) do set “dt=%%a” set “td.YY=%dt:~2,2%” set “td.YYYY=%dt:~0,4%” set “td.MM=%dt:~4,2%” set “td.DD=%dt:~6,2%” set “filename=%td.MM%%td.DD%%td.YY%.txt :loop for %%i in (%filename%) do ( echo %%~ai|find “a” >nul && ( cscript MessageBox.vbs “Today’s Schedule Changed. Modified … Read more

[Solved] Batch script that will allow to search a particular IP and change it to a new IP address in a .ini file

Try below updated code, please let me know if you still face issues cls @Echo Off SetLocal EnableDelayedExpansion if exist new.ini ( del /s /q new.ini ) set “search=1.1.1.1” set “search2=2.2.2.2” set “replace=7.7.7.7” set “replace2=8.8.8.8” for /F “tokens=*” %%a in (Apservice.ini) Do ( Set “filevalue=%%a” Set filevalue=!filevalue:%search%=%replace%! Set filevalue=!filevalue:%search2%=%replace2%! Echo !filevalue!>>new.ini ) move /y new.ini … Read more

[Solved] How to get the drive letter of a drive with a specific drive name on Windows? [closed]

A batch file code for copying the folder IMPDoc from drive on which the batch file is stored to a drive with volume name Files is: @echo off setlocal EnableExtensions DisableDelayedExpansion for /F “skip=1″ %%I in (‘%SystemRoot%\System32\wbem\wmic.exe LOGICALDISK where VolumeName^=”Files” GET DeviceID 2^>nul’) do ( %SystemRoot%\System32\robocopy.exe “%~d0\IMPDoc” “%%I\IMPDoc” /R:1 /W:1 /NDL /NFL /NJH /NJS goto … Read more

[Solved] Batch file v PowerShell script

The following code executes the same code via both processes: internal class Program { private static void Main() { const string COMMAND = @”SCHTASKS /QUERY /XML ONE”; Collection<PSObject> psObjects; using (var ps = PowerShell.Create()) { ps.AddScript(COMMAND); psObjects = ps.Invoke(); } var process = new Process { StartInfo = new ProcessStartInfo { UseShellExecute = false, RedirectStandardOutput … Read more

[Solved] Using IF statements with multiple conditions

I suppose you could use delayed expansion and remove the nested If statements too: @Echo Off SetLocal EnableDelayedExpansion Set “i=” For /F “Delims=” %%A In (‘Where .:???.mp3 2^>Nul’)Do ( If 1%%~nA Gtr 1000 Set “i=1” If 1%%~nA Gtr 1003 Set “i=2” If 1%%~nA Gtr 1006 Set “i=3” If 1%%~nA Gtr 1020 Set “i=4” If 1%%~nA … Read more