在特定目录中递归创建文件夹

发布于 2024-10-04 14:32:59 字数 265 浏览 0 评论 0原文

在最近的备份/恢复周期中,我意识到我设法省略了“.svn”目录中的“tmp”目录,因此我无法更新我的工作副本。如果我手动创建一个新的空“tmp”目录,问题就会消失,因此我正在寻找一种方法来递归地遍历每个文件夹,找到“.svn”文件夹并在其中创建一个“tmp”文件夹。

因为我不想弄乱现有的文件夹,所以我想在做一些愚蠢的事情之前寻求帮助:)

评论/建议将不胜感激,谢谢!

PS:这是在 Windows 机器上,所以遗憾的是 Bash 和其他 unix 实用程序不存在。

During a recent backup/restore cycle I've realized that I managed to omit the 'tmp' directories from within the '.svn' directories, and because of this I can't update my working copies. The problem goes away if I manually create a new, empty 'tmp' directory so I am looking for a way to recursively go through each folder, find '.svn' ones and create a 'tmp' folder inside them.

As I don't want to mess up the existing folders I thought I's ask for help before I did something silly :)

Comments/suggestions will be appreciated, thanks!

PS: This is on a Windows machine so sadly Bash and other unix utilities are not present.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

如若梦似彩虹 2024-10-11 14:32:59

上面的脚本在我的 Windows 7 机器上不起作用。 “dir /b /s .svn”没有获取所有目录,我收到“找不到文件”错误。

我将脚本更改为除了选择目录之外还包含 /ad,这有效!这是对我有用的脚本。

@echo off
for /f "usebackq delims=" %%I in (`dir /ad /b /s .svn`) do (
echo Fixing %%I...
mkdir "%%I\tmp"
)

The script above doesn't work on my on Windows 7 machine. The "dir /b /s .svn" doesn't get all dirs, I get a "File Not Found" error.

I changed the script to have /ad in addition to select directories only and that works! Here is the srcipt which works for me.

@echo off
for /f "usebackq delims=" %%I in (`dir /ad /b /s .svn`) do (
echo Fixing %%I...
mkdir "%%I\tmp"
)
总以为 2024-10-11 14:32:59

取决于有多少人。

使用 Edit dirs.bat 列出目录

 dir/B/S .svn >dirs.bat

在您选择的编辑器中 。在每行的开头添加 md (因为每行都以 C: 之类的内容开头,您可以使用相当愚蠢的编辑器 - 包括记事本 - 将 C: 更改为 md C: ).将 /tmp 添加到每行末尾(将 .svn 替换为 .svn\tmp)。节省。运行 BAT 文件

工作完成。

Depends on how many there are.

List the directories with

 dir/B/S .svn >dirs.bat

Edit dirs.bat in your editor of choice. Add md at the beginning of each line (since each line begins with something like C: you can use a fairly dumb editor - including notepad - to change C: to md C: ). Add /tmp to the end of each line (replace .svn with .svn\tmp). Save. Run the BAT file

Job done.

小鸟爱天空丶 2024-10-11 14:32:59

以下是如何自动化整个过程。将以下内容放入 fixtmp.cmd 等文件中:

@echo off
for /f "usebackq delims=" %%I in (`dir /b /s .svn`) do (
echo Fixing %%I...
mkdir "%%I\tmp"
)

Here's how to automate the entire process. Put the following in a file like fixtmp.cmd:

@echo off
for /f "usebackq delims=" %%I in (`dir /b /s .svn`) do (
echo Fixing %%I...
mkdir "%%I\tmp"
)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文