batch-file

Loop through code batch file

。_饼干妹妹 提交于 2021-02-04 20:54:05
问题 I have done a batch file to help me doing a measurement but I don't know how to put it in a for-loop to make it for n times and to change the name of the folder in "Results" as it changes in the for loop (here I have 01 but just for one measurement time without for loop). This is the code that I have done: @echo off @set var1=var1.exe @set var2=C:\...\...\... .txt @set Results=C:\....\Results\01 Mkdir %Results% %var1% %var2% %Results% I tried to use this code: FOR /L %%A IN (1,1,10) DO (

Batch/Macro code to get latest file from FTP site

久未见 提交于 2021-02-04 19:58:38
问题 We have a shared FTP site with a daily file upload which I need to download and run checks over. I'm simply trying to automate the process. The FTP file is something like name_20150901.xml . So far I have a batch file to get the file but I can't figure out how to get the latest. Here is my code: @ftp -i -s:"%~f0"&GOTO:EOF open ftp.site.com <user> <pass> lcd my local direc binary get todaysfile_20150901.xml What changes do I need to read the files and get the newest one? My end goal is to have

How to copy files using a batch file? [duplicate]

怎甘沉沦 提交于 2021-02-04 19:54:30
问题 This question already has answers here : How do I copy files using Windows Batch? (6 answers) Closed 2 years ago . I need to create a batch file to copy certain files (e.g., 19_1_White.jpg) to a folder within the directory. How can I do this? 回答1: XCOPY F:\*.* G:\ /C /S /D /Y /I XCOPY allows for copying of files, directories, and sub directories. F:\*.* is our source location G:\ is our destination location /C tells XCOPY to ignore errors, and finish what can be done /S tells XCOPY to copy

How to copy files using a batch file? [duplicate]

天大地大妈咪最大 提交于 2021-02-04 19:54:18
问题 This question already has answers here : How do I copy files using Windows Batch? (6 answers) Closed 2 years ago . I need to create a batch file to copy certain files (e.g., 19_1_White.jpg) to a folder within the directory. How can I do this? 回答1: XCOPY F:\*.* G:\ /C /S /D /Y /I XCOPY allows for copying of files, directories, and sub directories. F:\*.* is our source location G:\ is our destination location /C tells XCOPY to ignore errors, and finish what can be done /S tells XCOPY to copy

Delete file with specific extension in batch file

眉间皱痕 提交于 2021-02-04 18:50:37
问题 I would like to recursively delete all files with a specific extension in a batch file. I am aware of the following command: del /s *.ext However, this does on Windows also delete files with other extensions like e.g. .ext1 or .ext2 . The reason for this seems to be that the 8.3 file name of such a file ends with .ext and therefore also the files with longer extensions are matched. I am looking for a replacement to the command above that recursively deletes all files with .ext extension but

Get Parent directory of a specific path in batch script

孤者浪人 提交于 2021-02-04 11:33:31
问题 Hi I have full file path in a variable of batch file. How to get its first and second level parent directory path? set path=C:\SecondParent\FirstParent\testfile.ini 回答1: do not use variable PATH for this. %PATH% is a built-in variable used by the command prompt. @echo off set "_path=C:\SecondParent\FirstParent\testfile.ini" for %%a in ("%_path%") do set "p_dir=%%~dpa" echo %p_dir% for %%a in (%p_dir:~0,-1%) do set "p2_dir=%%~dpa" echo %p2_dir% 回答2: As npocmaka correctly suggests, pick a

Open URL that contains umlaut with batch

我的未来我决定 提交于 2021-02-04 08:11:50
问题 I want to open an URL in chrome with a batch file. This works for normal URLs, but it doesn't for URLs with umlauts. start chrome.exe https://trends.google.de/trends/explore?q=mähroboter I cannot use "ae" as a replacement for "ä", as it will give me different results on Google Trends. When I keep it like this, the URL in my browser changes to https://trends.google.de/trends/explore?q=mA4hroboter which again gives me the wrong results. It needs to be "ä". I tried playing around with the file

Batch function not working correctly

萝らか妹 提交于 2021-01-29 21:00:34
问题 A while ago I made a function that you can call from the command prompt or any batch file (it was just for fun, I don't see how it could be useful). It basically just makes your (Microsoft) computer speak whatever you wrote in as the parameter. I recently got some inspiration to add a switch to it where it would read the contents of a file. My standalone script worked, but when I added it to my function, it didn't work as I would have liked. Here's the code: @echo off & setlocal

Batch copying a source file to certain subdirectories, with copy names based on files within? [duplicate]

十年热恋 提交于 2021-01-29 20:28:47
问题 This question already has an answer here : Variables are not behaving as expected (1 answer) Closed last month . As it says in the title, I have a need to copy a source txt file to any number of tga files that reside within a certain set of subfolders in the directory, where the copies of the txt file have names matching the tga files there. Let's say I have a folder structure looking like this: destination1/aaa.tga destination1/bbb.tga destination2/aaa.tga otherfolder/ccc.tga ddd.tga copyme

Windows CMD FINDSTR STRING AND COPY FILE

半城伤御伤魂 提交于 2021-01-29 19:29:55
问题 I have a folder with subfolders include txt and pdf files. There is a Pdf file for each txt file which has nearly same name. For example; for each ABC_R10.txt --> there is a ABC).pdf file. In Windows 10, with a batch file, I want to search specific string in a .txt file with FINDSTR command, and copy files, which contain my string, into current folder. I achieved proper code until this point. CLS @ECHO OFF ECHO FIND BUKUM findstr /m /s /i /p /c:"BUKUM" *.txt > logfile.xls for /f "delims=" %%a