gpt4 book ai didi

batch-file - 批处理文件 |父目录

转载 作者:行者123 更新时间:2023-12-02 22:31:34 25 4
gpt4 key购买 nike

见鬼,我是批处理文件的新手我有一个批处理文件,如:

@ECHO OFF
if not exist To_delete mkdir To_delete
if not exist resources mkdir resources
copy "C:\icon.png" "resources"

cd /d To_delete
echo The current folder is : "%CD%"
echo The icon.png is located at "CODE_I_NEED_IS_HERE"

The result should be:
The current folder is : C:\Users\Leona\Desktop\To_delete\
The icon.png is located at C:\Users\Leona\Desktop\Resource\

注意:我不想通过CD在该文件夹中获取icon.png的路径,我想要的是在当前文件夹为“To_delete”时检索resources文件夹中的文件。

谢谢。

最佳答案

@ECHO OFF
if not exist To_delete mkdir To_delete
if not exist resources mkdir resources
copy "C:\Documents and Settings\mlastg\Desktop\logo.png" "resources"

cd /d To_delete
echo The current folder is : "%CD%"
dir /s/b/A:-D "%CD%\..\resources"

最后一条命令将为您提供资源文件夹中所有文件的路径。现在您可以详细说明以获得答案

C:\Documents and Settings\mlastg\Desktop>batch.bat
1 file(s) copied.
The current folder is : "C:\Documents and Settings\mlastg\Desktop\To_delete"
C:\Documents and Settings\mlastg\Desktop\resources\logo.png

关于batch-file - 批处理文件 |父目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12160121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com