首页 > 其他分享 >[901] Reuse variables of CMD batch scripts

[901] Reuse variables of CMD batch scripts

时间:2023-10-10 09:13:31浏览次数:37  
标签:paths 901 Reuse variables base file variable path txt

In a batch file, you can reuse a variable to generate different file paths by concatenating the variable with other strings or variables. Here's an example of how to do this:

@echo off
set "base_path=C:\Example"

REM Generate file paths using the base_path variable
set "file1=%base_path%\file1.txt"
set "file2=%base_path%\file2.txt"
set "file3=%base_path%\file3.txt"

REM Display the generated file paths
echo File 1: %file1%
echo File 2: %file2%
echo File 3: %file3%

In this example:

  1. We set a base path using the base_path variable, which is C:\Example.

  2. We generate different file paths by concatenating the base_path variable with specific file names (e.g., file1.txt, file2.txt, and file3.txt) and store them in separate variables (file1, file2, and file3).

  3. We use the echo command to display the generated file paths.

When you run this batch file, it will display the following output:

File 1: C:\Example\file1.txt
File 2: C:\Example\file2.txt
File 3: C:\Example\file3.txt

You can reuse the base_path variable to generate different file paths by changing the file names or appending additional folder names as needed.

标签:paths,901,Reuse,variables,base,file,variable,path,txt
From: https://www.cnblogs.com/alex-bn-lee/p/17753703.html

相关文章

  • Codeforces Round 901 (Div. 2) C. Jellyfish and Green Apple (位运算)
    CodeforcesRound901(Div.2)C.JellyfishandGreenApple//思路:浮点数转二进制,a/b的结果为gcd(a,b)*最简分式(n/m)的结果//苹果能分的前提是人数得是一个2的次幂数,通过切割只能分为形同0.001的二进制小数//a/b的二进制如果在从左到右的sp位为1,则需要切割到这个情况//一个......
  • ‘Proof of the pudding’: Global variables and PAGE_EXECUTE_WRITECOPY
    ‘Proofofthepudding’:GlobalvariablesandPAGE_EXECUTE_WRITECOPYUNCATEGORIZEDPRODUCTIONDEBUGGING, WINDBGLEAVEACOMMENT TodayIwasteachingadebuggingclasstoourcustomers.Asafoundationalelementwenormallyreviewthevirtual-to-phys......
  • P9019 [USACO23JAN] Tractor Paths P 题解
    Description有\(n\)个区间,第\(i\)个区间为\([l_i,r_i]\)。保证\(l_1<l_2<\cdots<l_n\)且\(r_1<r_2<\cdots<r_n\)。其中一部分区间是特殊的,输入会给定。如果第\(i\)个区间和第\(j\)个区间相交,那么\(i,j\)之间有一条边。保证\(1,n\)联通。给定\(Q\)组询问,每次......
  • P3901 数列找不同 【莫队】
    P3901数列找不同莫队:一种离线处理的优化暴力解法,时间复杂度在n*n^(1/2),会被卡常数,但是极为简单推荐视频:莫队算法点击查看代码#include<bits/stdc++.h>usingnamespacestd;constintN=1e5+10;inta[N];intpos[N];structnode{ intl,r,k;}t[N];strings......
  • Codeforces Round 901 (Div. 2)
    目录写在前面ABCDE写在最后写在前面比赛地址:https://codeforces.com/contest/1875。爱丽数码我真的好喜欢你啊为了你我要定制你的帆布包口牙!!!!A显然只会在剩余时间为1时使用工具,模拟即可。///*By:Luckyblock*/#include<bits/stdc++.h>#defineLLlonglong//========......
  • 题解 Codeforces Round 901 (Div. 1) / CF1874A~E
    题解CodeforcesRound901(Div.1)/CF1874A~E比赛情况:过了AB。赛后发现B是假复杂度。https://codeforc.es/contest/1874A.JellyfishandGameProblemAlice&Bob又在博弈,Alice手上有\(n\)个苹果,第\(i\)个苹果的价值是\(a_i\);Bob手上有\(m\)个苹果,第\(i\)......
  • Java 21 新特性:Unnamed Patterns and Variables
    Java21中除了推出JEP445:UnnamedClassesandInstanceMainMethods之外,还有另外一个预览功能:未命名模式和变量(UnnamedPatternsandVariables)。该新特性的目的是提高代码的可读性和可维护性。下面通过一个例子来理解这个功能,try-catch块相信大家都不陌生,都是这样写的:try{......
  • Codeforces Round 901 (Div
    C.JellyfishandGreenApple题解显然\(n\%m=0\),答案一定为\(0\)如果\(n>m\),我们显然可以将\(n/m\)的苹果分给每个人,然后再处理$n%m$如果\(n<m\),我们一定会将所有苹果一直对半切直到\(n>m\),所以答案每次对半切一定会加\(n\)直到\(n\%m=0\)的时......
  • Codeforces Round 901 (Div. 2)
    CodeforcesRound901(Div.2)A-JellyfishandUndertale解题思路:卡在最后秒放。若\(x_i>(a-1)\):那么该\(x_i\)的贡献为\(a-1\)。否则,该\(x_i\)的贡献为\(x_i\)。代码:#include<bits/stdc++.h>usingnamespacestd;usingll=longlong;typedefpair<int,in......
  • 901DIV2 (A~D)
    901DIV2A~DA:大于等于\(a-1\)的贡献都是a-1.voidsolve(){intans=0;inta,b,n;cin>>a>>b>>n;ans+=b;for(inti=1;i<=n;i++){intx;cin>>x;if(x>=a)x=a-1;ans+=x;}cout<<......