batch-file

Moving and renaming files, keeping extension but include sub directories in batch file

可紊 提交于 2020-01-16 18:20:07
问题 Forgive me if this is nor the place to ask these questions, I am new to batch and scripts and a bit new to these kind of posts... I have a folder that will receive files and folders, I want to run a script that looks at the directory and renames all files in each subfolder numerically, and moves them if possible. For example I have something that looks like the following Recieved_File_Folder |_folder1 | |_file1.txt | |_file2.bmp |_folder2 | |_file4.exe | |_file5.bmp |__file9.txt |__file10.jpg

How to select multiple files using the BATCH selector?

家住魔仙堡 提交于 2020-01-16 14:47:00
问题 I need to amend the code given so that the code selects multiple files at once. After file selection, I want to save the amount of files selected in a variable. I also need a variable to save the directory path of the file. For example: C: \Users\Andrew\Desktop . And finally, I need another variable to save the extension of the selected files (I'm assuming all files have the same extension). Example: In the File.txt file, txt is saved. I hope you can help me. rem preparation command set

BATCH/CMD: Print each line of a .txt into a variable

China☆狼群 提交于 2020-01-16 12:46:12
问题 Goal: Have every dll file in a computer passed into regsvr32.exe Accomplished: cd\ ::REM Exports every file and directory (/s) into a file in root of c: called dir.txt with only file names (/b) dir /s /b>>dir.txt ::REM Now, this will contain every extension type. We only want dll's, so we findstr it into dll.txt: findstr ".dll$" dir.txt>>dll.txt The Kink: Now, if I want to regsvr32.exe "file" every file that is now in dll.txt, I somehow need to get out every individual filename that is

BATCH/CMD: Print each line of a .txt into a variable

▼魔方 西西 提交于 2020-01-16 12:43:52
问题 Goal: Have every dll file in a computer passed into regsvr32.exe Accomplished: cd\ ::REM Exports every file and directory (/s) into a file in root of c: called dir.txt with only file names (/b) dir /s /b>>dir.txt ::REM Now, this will contain every extension type. We only want dll's, so we findstr it into dll.txt: findstr ".dll$" dir.txt>>dll.txt The Kink: Now, if I want to regsvr32.exe "file" every file that is now in dll.txt, I somehow need to get out every individual filename that is

BATCH/CMD: Print each line of a .txt into a variable

↘锁芯ラ 提交于 2020-01-16 12:43:30
问题 Goal: Have every dll file in a computer passed into regsvr32.exe Accomplished: cd\ ::REM Exports every file and directory (/s) into a file in root of c: called dir.txt with only file names (/b) dir /s /b>>dir.txt ::REM Now, this will contain every extension type. We only want dll's, so we findstr it into dll.txt: findstr ".dll$" dir.txt>>dll.txt The Kink: Now, if I want to regsvr32.exe "file" every file that is now in dll.txt, I somehow need to get out every individual filename that is

batch works fine but “windows cannot find devcon.exe” in c# program

这一生的挚爱 提交于 2020-01-16 12:03:15
问题 I have a batch file which disables and enables some driver using windows devcon. when I run this batch file by double-clicking on it it works fine. However, I tried to run it from a C# program that I wrote using this line: System.Diagnostics.Process.Start("C:/*path to file*/file.bat"); it runs fine until it tries to open the devcon.exe and I get the following message: after that it continues to run smoothly. any ideas why it doesn't work from the C# program? p.s I can't post the batch code

how to get current day of todays date in batch file

拟墨画扇 提交于 2020-01-16 09:12:17
问题 If my system date is 25/09/2019 and time is 08.12 then i want output from batch file as 250920190812 But this code gives me 01 as output if i want to get day of todays date which is 25 echo Current day %date:~7,2% What is wrong? 回答1: System Locale differs on each system, so rather use something more robust that will give consistant results on each device, for instance here is an example that also incorporates vbs. @echo off echo >"%temp%\%~n0.vbs" s=DateAdd("d",0,now) : d=weekday(s) echo>>"

Batch code not working for space in the file name

痴心易碎 提交于 2020-01-16 08:50:11
问题 Trying to automate using batch file wherein it will display filename and number of records in the file in an Output.txt file.But if my filename has space, then it does not give number of records, instead it show the text following the space @echo off ( for %%n IN (*.*) do ( for /F "tokens=3" %%f in ('find /V /C "-------------" "%%n"') do ( echo %%n : %%f ) )) >output.txt 回答1: just use tokens=2,* , ignore token2. * means "take all the rest without tokenizing any more" @echo off ( for %%n IN (*

Random number generator not random in a batch file

假如想象 提交于 2020-01-16 08:49:08
问题 Trying to generate a random number and use it for variable value in Windows batch script file. Maybe I am missing something very basic, but something is not working here for me. Created a batch file named random_test.bat with the following content. SET rnumber=%random% echo %random% pause Running the file consecutively three times produces the following set of outputs: One C:\Users\user\Desktop>SET rnumber=28955 C:\Users\user\Desktop>echo 20160 20160 C:\Users\user\Desktop>pause Press any key

How to format date/time output in a Windows batch script?

落花浮王杯 提交于 2020-01-16 08:43:11
问题 I'm writing a simple batch script to get the last date/time of when a PC was rebooted. Found two simple ways: systeminfo | find /i "Boot Time" which outputs: System Boot Time: 5/4/2019, 5:04:44 AM wmic os get lastbootuptime which outputs: LastBootUpTime 20190504050444.500000-420 I'm basically looking to format the output of the second one to be the same or similar as the first one (something readable). On newer PCs, the first one works fine but most of our customers are still running Windows